sonic-pi

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

C++

Code. Music. Live.

WaveFile::ChunkReaders::DataChunkReader#convert_24_bit_samples

Since Ruby doesn't have a way to natively extract 24-bit values using pack/unpack,
unsigned bytes are read instead, and then every 3 is manually combined into a
signed 24-bit integer.
Since the sample data is little endian, the 3 bytes will go from least->most significant

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/chunk_readers/data_chunk_reader.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-WaveFile--ChunkReaders--DataChunkReader-convert_24_bit_samples-for-pr


# Commit to git

git add app/server/ruby/vendor/wavefile-0.8.1/lib/wavefile/chunk_readers/data_chunk_reader.rbgit commit -m "better docs for WaveFile::ChunkReaders::DataChunkReader#convert_24_bit_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--ChunkReaders--DataChunkReader-convert_24_bit_samples-for-pr

hub pull-request


# Celebrate!