sonic-pi

https://github.com/sonic-pi-net/sonic-pi

C++

Code. Music. Live.

WaveFile::Buffer#initialize

Creates a new Buffer.

samples - An array of samples. If the Format has 1 channel (i.e. is mono), this 
          should be a flat array of samples such as [0.5, 0.4, -0.3, ...]. If the 
          Format has 2 or more channels the array should include a sub-array for 
          each sample frame. For example, [[0.5, 0.2], [0.1, 0.6], [-0.2, 0.4], ...] 
          for a stereo file.

format - A Format instance which describes the sample format of the sample array. 

         Note that the sample array is not compared with the format to make sure 
         they match - you are on the honor system to make sure they do. If they
         don't match, unexpected things will happen.

Examples

  samples = ([0.5] * 50) + ([-0.5] * 50)   # A 440Hz mono square wave
  buffer = Buffer.new(samples, Format.new(:mono, :float, 44100)

  samples = ([0.5, 0.5] * 50) + ([-0.5, -0.5] * 50)   # A 440Hz stereo square wave
  buffer = Buffer.new(samples, Format.new(2, :float, 44100)

Returns a constructed Buffer.

Source | Google | Stack overflow

Edit

git clone [email protected]:sonic-pi-net/sonic-pi.git

cd sonic-pi

open app/server/ruby/vendor/wavefile-0.8.1/lib/wavefile/buffer.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-WaveFile--Buffer-initialize-for-pr


# Commit to git

git add app/server/ruby/vendor/wavefile-0.8.1/lib/wavefile/buffer.rbgit commit -m "better docs for WaveFile::Buffer#initialize"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-WaveFile--Buffer-initialize-for-pr

hub pull-request


# Celebrate!