Author Topic: GraMusic (Grammer)  (Read 5122 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: GraMusic (Grammer)
« Reply #15 on: February 24, 2012, 11:03:36 am »
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?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: GraMusic (Grammer)
« Reply #16 on: February 24, 2012, 11:05:54 am »
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

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: GraMusic (Grammer)
« Reply #17 on: February 24, 2012, 11:10:04 am »
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.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: GraMusic (Grammer)
« Reply #18 on: February 24, 2012, 11:17:28 am »
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.
« Last Edit: February 24, 2012, 11:18:43 am by Keoni29 »
If you like my work: why not give me an internet?








Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: GraMusic (Grammer)
« Reply #19 on: February 24, 2012, 02:23:19 pm »
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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: GraMusic (Grammer)
« Reply #20 on: February 24, 2012, 02:34:24 pm »
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

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: GraMusic (Grammer)
« Reply #21 on: February 24, 2012, 06:14:51 pm »
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
« Last Edit: February 24, 2012, 06:25:37 pm by TBO_Yeong »
Sig wipe!

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: GraMusic (Grammer)
« Reply #22 on: March 11, 2012, 12:50:57 am »
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 that can handle DMA. It even has a PCM wave buffer.

OK, sarcasm aside, sound synthesis is difficult because it has to be done via pure 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 116384 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.)
« Last Edit: March 11, 2012, 01:00:29 am by DrDnar »
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: GraMusic (Grammer)
« Reply #23 on: March 18, 2012, 05:23:08 pm »
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
Sig wipe!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: GraMusic (Grammer)
« Reply #24 on: March 18, 2012, 05:31:06 pm »
Actually, it might be better if I make this compatible with the MuseInc format >.>