Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting musical notes to a wav file
    primarykey
    data
    text
    <p>I am interested in how to take musical notes (e.g A, B, C#, etc) or chords (multiple notes at the same time) and write them to a wav file.</p> <p>From what I understand, each note has a specific frequency associated with it (for perfect pitch) - for example A4 (the A above middle C) is 440 Hz (complete list 2/3 of the way down <a href="http://www.dolmetsch.com/musictheory1.htm">This Page</a>). </p> <p>If my understanding is correct, this pitch is in the frequency domain, and so needs the inverse fast fourier transform applying to it to generate the time-domain equivalent?</p> <p>What I want to know is:</p> <ul> <li>How do chords work? Are they the average of the pitches?</li> <li>How is the length of time to play each note specified, when the contents of the wav file is a waveform?</li> <li>how is the result of multiple notes being inverse FFT'd converted to an array of bytes, which make up the data in a wav file?</li> <li>any other relevant information relating to this.</li> </ul> <p>Thanks for any help you can give. If giving code examples, I am using C# and the code I am currently using to create wav files is as follows:</p> <pre><code>int channels = 1; int bitsPerSample = 8; //WaveFile is custom class to create a wav file. WaveFile file = new WaveFile(channels, bitsPerSample, 11025); int seconds = 60; int samples = 11025 * seconds; //Create x seconds of audio // Sound Data Size = Number Of Channels * Bits Per Sample * Samples byte[] data = new byte[channels * bitsPerSample/8 * samples]; //Creates a Constant Sound for(int i = 0; i &lt; data.Length; i++) { data[i] = (byte)(256 * Math.Sin(i)); } file.SetData(data, samples); </code></pre> <p>This creates (somehow) a constant sound - but I don't understand completely how the code correlates with the result.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload