sonic-pi

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

C++

Code. Music. Live.

WaveFile::Duration#initialize

Constructs a new immutable Duration.

sample_frame_count - The number of sample frames, i.e. the number 
                     samples in each channel.
sample_rate - The number of samples per second, such as 44100

Examples:

  duration = Duration.new(400_000_000, 44100)
  duration.hours         # => 2
  duration.minutes       # => 31
  duration.seconds       # => 10
  duration.milliseconds  # => 294

Note that the hours, minutes, seconds, and milliseconds fields do not return 
the total of the respective unit in the entire duration. For example, if a 
duration is exactly 2 hours, then minutes will be 0, not 120.

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/duration.rb

Contribute

# Make a new branch

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


# Commit to git

git add app/server/ruby/vendor/wavefile-0.8.1/lib/wavefile/duration.rbgit commit -m "better docs for WaveFile::Duration#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--Duration-initialize-for-pr

hub pull-request


# Celebrate!