sonic-pi

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

C++

Code. Music. Live.

WaveFile::Buffer#samples

Returns the sample data contained in the Buffer as an Array. If the Format has 
1 channel, the Array will be a flat list of samples. If the Format has 2 or more 
channels, the Array will include sub arrays for each sample frame, with a sample 
for each channel.

Examples

  samples = mono_buffer.samples
  # => [-0.5, 0.3, 0.2, -0.9, ...]

  samples = stereo_buffer.samples
  # => [[-0.2, 0.5], [0.1, 0.2], [-0.4, 0.7], [0.1, 0.2], ...]

  samples = three_channel_buffer.samples
  # => [[0.3, 0.5, 0.2], [-0.1, 0.2, -0.9], [0.2, 0.3, -0.4], [0.1, 0.2, -0.8], ...]

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-samples-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#samples"


# 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-samples-for-pr

hub pull-request


# Celebrate!