Omnimaga
Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Xeda112358 on February 06, 2012, 05:14:55 pm
-
So I made this music player in Grammer >.> The download includes two quick samples. I'll be back in a few hours if anybody has questions :)
-
It looks nice :o
-
Thanks :D And it interprets the data, too (it doesn't compile anything yet), and it still works quickly :) I found out that prgmTEST1 is a part of "Ode to Joy" and apparently I have a few notes off D:
-
Looks cool! But why isn't this in the grammer section?
-
There isn't a Grammer section D: Also, apparently this still needs a bit of work >.> It works and I found it to work nicely, but it isn't overly amazing XD
-
Geez lots of music software around these days. It'd be nice to have some games with music in them.
-
Challenge accepted :P
-
O.O Usually it is difficult to do, but simple sound effects should not be hard :)
-
There isn't a Grammer section D: Also, apparently this still needs a bit of work >.> It works and I found it to work nicely, but it isn't overly amazing XD
http://www.omnimaga.org/index.php?board=202.0
-
There isn't a Grammer section D: Also, apparently this still needs a bit of work >.> It works and I found it to work nicely, but it isn't overly amazing XD
http://www.omnimaga.org/index.php?board=202.0
I think she meant like a grammer forum. ;)
Looks cool Xeda. I just can't tell of the screenshot how it sounds. :P
-
:P Also, I was not sure if Grammer programs should be uploaded there or here :/
-
O.O Usually it is difficult to do, but simple sound effects should not be hard :)
No sfx aren't hard to implement indeed, but music is possible. (maybe not with grammer, but with ASM or even Axe it'd be possible.)
-
Full background music would be pretty difficult as sound uses most of the CPU time. It would definitely work for simple games, but complicated games would be much slower :/ I hope somebody manages it, though! (As a note, the Grammer sound works about as fast as assembly) GraMusic sound does not work as fast as it could because it interprets the data instead of preparsing it :/
-
Generally grammer projects goes in the calc projects and ideas section. There isn't a Grammer projects section yet due to the small amount of such project so far. Eventually there will most likely be one, though, like Axe.
This seems nice by the way. I wonder if Grammer music can be used in the very middle of a game in action?
-
I'm sure somebody like Yeong could do it :D I have made sound at main menus before using a slower version of Grammer :]
-
Ah that's nice. Were the sounds playing as small beeps like in Pyoro, though? Or were they full length notes not stopping when stuff is happening?
-
Oh, just beeps, but I think I could get it to play notes pretty easily now. Before, I did it on a very old version of Grammer that had really crappy sound support. It might actually go well for back ground music in my checkers game since a lot of it is waiting for user input o.O
-
Ah ok. I remember some Axe programs played full notes instead of beeps and despite the sound quality being lower it still sounded quite OK. It would really be nice to see a calc game with background music.
-
Can't we just bind a timer to the port so that the program doesn't freeze every time a note has to be played? Also, I made this a while ago:
www.youtube.com/watch?v=7kK_vRbiibc (no comments about my voice please :P)
It plays the sfx on another calc so that they won't cause the game to freeze for a while.
-
You cannot easily "bind a timer to the port" per se, but you can play notes at a set time interval based on the game loop. For example, if I do this for Checkers, I will let it play through music data one note at a time while waiting for a key press.
-
Can't we just bind a timer to the port so that the program doesn't freeze every time a note has to be played? Also, I made this a while ago:
www.youtube.com/watch?v=7kK_vRbiibc (no comments about my voice please :P)
It plays the sfx on another calc so that they won't cause the game to freeze for a while.
Yeah I remember that and it was great. Of course that wouldn't work for everyone, though, since not everyone can afford to buy a second calc, let alone carry two calcs to play a game. :P
-
What I'll do is use one note as a "Pause".
(That's the way you can put music with MuseInc XD)
That way, music can "naturally" flow while the game is running.
If you make a song that has a continuous 32nd note or something (if the note is longer than that, make use of rests XD), it'll flow kinda nicely, imo,
However, the program should be fast enough X.o
-
Can't we just bind a timer to the port so that the program doesn't freeze every time a note has to be played?
Sure. The the calculator totally has a southbridge (http://en.wikipedia.org/wiki/Southbridge_(computing)) that can handle DMA (http://en.wikipedia.org/wiki/Direct_memory_access). It even has a PCM (http://en.wikipedia.org/wiki/PCM) wave buffer.
OK, sarcasm aside, sound synthesis is difficult because it has to be done via pure bit banging (http://en.wikipedia.org/wiki/Bit_banging). You could set up a crystal timer interrupt to handle changing the port status at a fixed rate, but it will sound terribly out of tune. The reason is that the maximum frequency that you can get interrupts to fire at is 32768 Hz. As a result, you have to quantize the period of each note to intervals of 1⁄16384 of a second. The human ear can hear frequency distortions of less than 1%. With such a synthesis technique, the error from the correct frequency will begin to exceed 1% around middle C.
If you're wondering, the quantized frequency of a frequency fn quantized to a half-frequency of fs (here, 16384) is fq(fn, fs) = fs/round(fs/fn)
The ideal frequency of piano key m is fm(m) = 440 * 2^((m-49)/12)
The percent distortion for a particular note n quantized to a half-frequency fs is fe(n, fs) = (fq(fm(n), fs) - fm(n)) / fm(n)
Go ahead and graph this on your calculator and you'll see the graph cross the 1% line for the first time at G#3.
Incidentally, this is why even simple delay-loop based music sounds slightly distorted. It's not the fact that the frequencies will differ from the ideal by a small percentage, it's the fact that those percentages are all different that makes the music sound out-of-tune. (Also, the square waves take some of the blame.)
-
any progress in here? :D
If it progress a bit, I'll add something in museinc that lets convert museinc appvar into gramusic format. :D
-
Actually, it might be better if I make this compatible with the MuseInc format >.>