Okay, so I have made sound routines in assembly before, but I really don't understand the technical aspects of it. I want to make a sound routine that is up to par with other sound programs, but for Grammer. Apparently the current routine isn't all that great XD
So if anybody could explain to me some key things about sound (like what a wave chart is), that would be great!
But that doesn't
explain anything to me. That is just pushing data at me that I don't understand yet :/
But this will be useful, I bet
there is a little links at the bottom of the page.
I saw those, so is there any way somebody could give me an example of creating these frequencies and wavelengths and whatnot? When I made the sound routines, I just made it so that lower numbers make higher pitches :/
Idk asm so I couldn't understand 75% of the code, but benryes' "quadplayer" in ticalc.org have a source code included. You can look that up.
XD I can't read code very easily unless I made it, but I can give it a try
There is a simple formula to calculate wavelength:
w = 1/f
Where w is wavelength in seconds, and f is frequency in Hertz.
For example, a 2000Hz tone has a wavelength of 0.0005 seconds (500 microseconds). To generate this tone, you could alternate the link output every 250 microseconds (because a cycle is two alternations). That is equivalent to 375 NOP instructions at 6MHz, or about 937 NOP's at 15MHz. Of course, you should also subtract the time spent by the OUT instruction or other instructions.
To step back a second, a wavelength is one cycle of a sine wave. It starts at 0, goes up to 1, down to -1, and back to 0. A perfect audio replication machine would make a voltage curve that was the same shape, starting at zero, going up to some positive voltage, then gradually down to some negative voltage, and back to zero. This would make a speaker vibrate at exactly that frequency, and you'd hear the corresponding note. Unfortunately, the calculator's link line has exactly two states, on and off. Therefore, we create a (very) rough approximation of a sine wave with something called a square wave, which is at 1 for w/2 and 0 for w/2.
Thanks christop and Kerm, this helps much! Putting it in terms of cycles kind of unlocked my brain, so now I know how I can try this.
To be honest, I forgot about making this topic (I must have been really tired), but I just checked my email and saw the notification buried under a bajillion and a half emails, so I am thankful for notifications!