scottmacphersonmusic / music_thurry

0 stars 0 forks source link

Modify MusicTheory::Note to take an envelope #3

Open bion opened 9 years ago

bion commented 9 years ago

stop the goddamn clicking

something like

MusicTheory::Note.new(
  frequency: freq,
  duration: 0.33,
  output_file_name: 'giant_steps',
  distort: true,
  envelope: env
).play

where env is an object that specifies an amplitude curve for the note to follow as it plays

bion commented 9 years ago

note that it needs to be applied before distortion

scottmacphersonmusic commented 9 years ago

Does this imply forking/cloning the original music_theory source and building onto it? Maybe I should tie my Pitch class into that and amend MusicTheory::Note to accept pitch names as well as frequencies (I think you mentioned doing this and having it accept midi values as well?)?

Do you have any recommended sources for reading about envelopes?

bion commented 9 years ago

yep, you're gonna need to fork that other repo

bion commented 9 years ago

use a Gemfile to manage the dependencies in this project so you can specify that you want your version of it e.g. Gemfile

gem 'music_theory' :git => 'https://github.com/scottmacphersonmusic/music_theory.git'

more info on bundler and the Gemfile: http://bundler.io/

bion commented 9 years ago

envelopes: http://en.wikipedia.org/wiki/Envelope_%28waves%29

basically, this is a way to control the amplitude of the note over its duration. you can make this as simple or as complicated as you want.

a simple implementation may involve having several pre-determined envelopes that can be scaled to the duration of a note e.g. Envelope.percussive could create an envelope that goes from 0 to 1 in 0.01 seconds, and then takes the rest of the duration of the note to return to 0.

more complex functionality could allow the user to specify the envelope at creation time e.g. Envelope.new([0, 1, 0.2, 0], [0.1, 0.3, 0.6]) would create an envelope that goes from 0 to 1 for the first 10% of the note, 1 to 0.2 for the following 30%, and then 0.2 to 0 for the remaining 60% (fun fact: this is similar to the default interface SuperCollider provides for creating envelopes)

bion commented 9 years ago

at the lowest level, you should be able to use an envelope to get a value to multiply by each sample to scale it the sine wave to a specific amplitude. those scaling values will always be 0 <= scaling_value_from_envelope <= 1

scottmacphersonmusic commented 9 years ago

I'm a little confused about the directory structure. At this point I have two separate projects: music_thurry (which I've been working on) and a clone of Ben Egget's music_theory.

~/Projects /music_theory /all dat cloned shit /music_thurry /all my shit

My understanding is that I'll now be incorporating some of the stuff I've written into music_theory. Is that correct and will the Gemfile i'm adding the above-mentioned line to be the one that's already in music_theory? such confuse

scottmacphersonmusic commented 9 years ago

it collapsed my whitespace... music_theory and music_thurry are subdirectories of /Projects

bion commented 9 years ago

The Gemfile will go into music_thurry and will contain the line from above. When you you run bundle from the command line in music_thurry, it will clone your forked version of music_theory to install it locally. Then, as you make changes to music_theory (and push them up to github), you can update the version you're using in music_thurry with those changes by running bundle update --source music_theory.