Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: zero44 on April 28, 2011, 04:12:13 pm

Title: An Axe piano with 5 octaves
Post by: zero44 on April 28, 2011, 04:12:13 pm
Hello,

I less than 1 hour, I made a piano in Axe, which can play sound on five octaves.
(Axe sound in Hertz : Freq(32768/Hz, TIME) )
I add a picture, a mix of 8 white keys, 5 blacks, and a hole at the end of each key :
When we press a key, I make sound, and a X ( for blacks ) or a little donut ( whites ) go out of the key  :hyper:

You need to take your calc with the screen on your left, and the port on your right.
To play a note, press the key as it were a real piano : the [2nd] to [->] keys are the 8 whites, and to play black keys, its the key just over the white :
C note is [2nd], C# is [mode], D is [alpha], D# is [xtOn], etc.
with [▲] or [apps] you can go down of an octave, and go up with [▼] or [1].

I'll put codes soon, and a gif in 2 weeks ( no wabbitemu here, in vacations ...  :'()
Title: Re: An Axe piano with 5 octaves
Post by: Yeong on April 28, 2011, 04:15:52 pm
oooh nice.
Does it support multiple notes?
I tried to do it one time, and I managed to make it produce 2 notes at a same time, but it barely works so XP
Title: Re: An Axe piano with 5 octaves
Post by: Xeda112358 on April 28, 2011, 04:19:30 pm
Very cool, nice! I don't know much about music, but I want to make a sound player on my calc now XD
Title: Re: An Axe piano with 5 octaves
Post by: zero44 on April 28, 2011, 04:19:45 pm
?!.
How can you make two sounds with axe ?
If two notes are pressed, only the higher is played.

Just a bug : the sound quality is ...  :banghead: (like this ^^)
I tried interrupts, but can you explain me how it works ? After many seconds I've no more sound...  :(
Title: Re: An Axe piano with 5 octaves
Post by: ZippyDee on April 28, 2011, 04:20:45 pm
This is great! I was thinking about making a guitar program at some point. :P I'll have to find a way to defy reality and play 6 notes at once though xD


?!.
How can you make two sounds with axe ?
If two notes are pressed, only the higher is played.

One way is to alternate back and forth between the two frequencies very quickly.
Title: Re: An Axe piano with 5 octaves
Post by: Xeda112358 on April 28, 2011, 04:21:19 pm
Maybe you have to detect both keys and then play one after the other real fast? Is there a way to really "mix" sounds?
Title: Re: An Axe piano with 5 octaves
Post by: Yeong on April 28, 2011, 04:21:53 pm
well, as i said, it barely works.
This is what I did:

for(A, 0, 100
freq(314,400
pause 10
freq(284,400
pause 10
End

Doesnt work on most of it(it sounds wierd) but it works.

EDIT: oh btw, i tried when i was porting music
EDIT2: ninja'd, ninja'd. pity me.
Title: Re: An Axe piano with 5 octaves
Post by: zero44 on April 28, 2011, 04:22:40 pm
Yeah, I thought too to a guitar...
I wanted to do guitar hero ^^

But have you an easy-to-do game idea with this ?
Title: Re: An Axe piano with 5 octaves
Post by: ZippyDee on April 28, 2011, 04:23:03 pm
Technically, when you're hearing multiple notes it's really just a combination of the frequencies. But that's just simple physics of adding and subtracting waves.
Title: Re: An Axe piano with 5 octaves
Post by: Yeong on April 28, 2011, 04:24:24 pm
supporting "real" multiple notes is what I really want in Axe.
Title: Re: An Axe piano with 5 octaves
Post by: Xeda112358 on April 28, 2011, 04:24:52 pm
Cool! I made a guitar hero like game that used sound, but not in Axe :/
Title: Re: An Axe piano with 5 octaves
Post by: zero44 on April 28, 2011, 04:25:35 pm
good night .
XD.
Title: Re: An Axe piano with 5 octaves
Post by: Munchor on April 28, 2011, 04:26:42 pm
If you release it I could make a video of Wabbit with sound :D This looks cool though
Title: Re: An Axe piano with 5 octaves
Post by: Stefan Bauwens on April 28, 2011, 04:27:28 pm
Sounds nice.
 I wish you luck with it!
Title: Re: An Axe piano with 5 octaves
Post by: Xeda112358 on April 28, 2011, 04:27:34 pm
Does Wabbit record sound, too?
Title: Re: An Axe piano with 5 octaves
Post by: ZippyDee on April 28, 2011, 04:28:40 pm
supporting "real" multiple notes is what I really want in Axe.
Conceptually that's pretty simple. Say you have the equation for three notes, f(t) g(t) h(t). The amplitude at any given t would just be f(t)+g(t)+h(t). Sum them all up. But it's not quite as easy when it comes to actually writing that out so it runs fast enough to produce the correct sound output with a chip like the z80 :P
Title: Re: An Axe piano with 5 octaves
Post by: Munchor on April 28, 2011, 04:29:22 pm
Does Wabbit record sound, too?

It does, you just have to 'tick' that option in the menu.
Title: Re: An Axe piano with 5 octaves
Post by: Adriweb on April 28, 2011, 04:34:55 pm
Nice !

Looks like what I programmed back in the days ...
http://www.ticalc.org/archives/files/fileinfo/405/40553.html (http://www.ticalc.org/archives/files/fileinfo/405/40553.html)
(http://www.ticalc.org/archives/files/ss/767/76713.gif)


EDIT :

Actually, this composer is what I meant :
http://ti.bank.free.fr/index.php?mod=archives&ac=voir&id=986 (http://ti.bank.free.fr/index.php?mod=archives&ac=voir&id=986)
(http://tiforge.info/zcontest/screens/alpha2.gif)
Title: Re: An Axe piano with 5 octaves
Post by: ralphdspam on April 28, 2011, 10:39:48 pm
Sounds like a great program!  I'm so glad to see the new programs with sound.  :)
Title: Re: An Axe piano with 5 octaves
Post by: Michael_Lee on April 29, 2011, 01:42:55 am
This is great! I was thinking about making a guitar program at some point. :P I'll have to find a way to defy reality and play 6 notes at once though xD


?!.
How can you make two sounds with axe ?
If two notes are pressed, only the higher is played.

One way is to alternate back and forth between the two frequencies very quickly.

The problem with oscillation is that if you go too fast, it sounds like crap, but if you go too slow, it doesn't sound blended.

The problem becomes even worse if you press like five keys at the same time X.X
Title: Re: An Axe piano with 5 octaves
Post by: zero44 on May 07, 2011, 02:54:14 pm
how to use interrupts in axe ?
I could make a better sound ...

-_-" I lost the pic needed by the program ...
I have to remake it.
Title: Re: An Axe piano with 5 octaves
Post by: thepenguin77 on May 07, 2011, 03:14:31 pm
supporting "real" multiple notes is what I really want in Axe.
Conceptually that's pretty simple. Say you have the equation for three notes, f(t) g(t) h(t). The amplitude at any given t would just be f(t)+g(t)+h(t). Sum them all up. But it's not quite as easy when it comes to actually writing that out so it runs fast enough to produce the correct sound output with a chip like the z80 :P

Yep, that is all it takes to play multiple notes at once. Just add up all the sine waves and output the new weird looking wave.

However, the calculator can only output a 1 or a 0, so how do you pull off all the intermediate steps of the new wave? That is where the real trouble comes in to play. For this, you would have to make your own version of freq() whereby using Pulse Width Modulation, (turning the link port on and off really fast), you simulate say, 32 different voltage steps. (That might be the most grammatically strange sentence I've written on Omni)
Title: Re: An Axe piano with 5 octaves
Post by: ralphdspam on May 07, 2011, 04:16:24 pm
how to use interrupts in axe ?
I could make a better sound ...

Yep, just use FnInt(LBL, FREQ)
Freq is 0-6, 6 being the slowest.
Make sure that the LBL location is formatted as a sub program (with a Return at the end).

Also, you can't use L2 while you are running custom interrupts.

At the end of the program, make sure to use LnReg.  If you don't, it will cause a ram clear.  ;)
Title: Re: An Axe piano with 5 octaves
Post by: zero44 on May 08, 2011, 03:24:40 pm
What do FnOn and FnOff ?
I tried with interupts, I had sound for 2 seconds, but I don't remember if I used FnOn or FnOff ...  ::)
I remade the picture, I give you codes .

Title: Re: An Axe piano with 5 octaves
Post by: Munchor on May 09, 2011, 07:30:14 am
Actually, aeTIos made a music composer & player in Axe, looking very good.
Title: Re: An Axe piano with 5 octaves
Post by: Yeong on May 09, 2011, 07:53:05 am
really? Can I haz a link?
Title: Re: An Axe piano with 5 octaves
Post by: ZippyDee on May 09, 2011, 08:09:45 am
Yep, that is all it takes to play multiple notes at once. Just add up all the sine waves and output the new weird looking wave.

However, the calculator can only output a 1 or a 0, so how do you pull off all the intermediate steps of the new wave? That is where the real trouble comes in to play. For this, you would have to make your own version of freq() whereby using Pulse Width Modulation, (turning the link port on and off really fast), you simulate say, 32 different voltage steps. (That might be the most grammatically strange sentence I've written on Omni)

It's exactly as thepenguin77 said: use Pulse Width Modulation. To explain PWM a bit better, why don't I give an example of some basic PWM.
An nice, simple example would be something like having an LED fade on and off. LEDs have two states: ON and OFF. So how do you fade it? The idea is the same as grayscale on a monochrome calculator screen: some of the time it's turned on, and some of the time it's turned off. But the switch is done very quickly. You can think of it as pulsing on and off. Pulse Width Modulation means changing the width (length) of the on/off pulses.

In this case, thepenguin77 mentioned simulating 32 voltage steps. Basically, that means that every 32 1's or 0's you send represents one pulse. You then change how much of that time you're sending a 1 or sending a 0 to change the pulse frequency. So for fading an LED, the pulses would look something like:

Code: [Select]
00000000000000000000000000000000 (Lowest possible step);
10000000000000000000000000000000
11000000000000000000000000000000
...
11111111111111110000000000000000
11111111111111111000000000000000
11111111111111111100000000000000
...
all the way up to
...
11111111111111111111111111111100
11111111111111111111111111111110
11111111111111111111111111111111 (Highest possible step)

That would fade it from being completely off, to completely on. The same idea goes for varying the frequencies that you are playing, though it's obviously a lot less linear.
Title: Re: An Axe piano with 5 octaves
Post by: zero44 on May 09, 2011, 08:51:00 am
How do you find the piano ?
I'm trying interrupts, with what ralphdspam said.

EDIT: I've no headphones here ... -_-'
Title: Re: An Axe piano with 5 octaves
Post by: aeTIos on May 09, 2011, 09:26:24 am
Actually, aeTIos made a music composer & player in Axe, looking very good.
It was Michael_Lee i think, I never made a sound program. :)
Title: Re: An Axe piano with 5 octaves
Post by: zero44 on May 09, 2011, 02:27:54 pm
Interrupts does not work.
Title: Re: An Axe piano with 5 octaves
Post by: zero44 on October 10, 2011, 02:42:01 pm
Hey !
I'm back here.

Big update for TI-Piano (see under), with a menu with options to change keys.
Now you can modify 'note density' and keys to change of octave.

To compile it:
Launch PIAN0 (TI-Basic prgm which will draw & store pic)
Restore backup AXEPIANO.8xv and compile it.
I'm not sure that it will work on Axe 1.*.*; but add spaces and it should be working.

Enjoy !
(I make a 7-octaves piano, but on old version ... )
Title: Re: An Axe piano with 5 octaves
Post by: mrmprog on October 10, 2011, 03:02:50 pm
Wow, that looks awesome! /me will download
Title: Re: An Axe piano with 5 octaves
Post by: parserp on October 10, 2011, 03:52:03 pm
O.O wow  XD

... and the new emoticon...
:trollface:
Title: Re: An Axe piano with 5 octaves
Post by: LincolnB on October 11, 2011, 10:39:45 am
?!.
How can you make two sounds with axe ?

Alternate between them, really fast.

EDIT: Okay, that was basically useless. My bad. I'll be sure to check out this program as soon as I can!
Title: Re: An Axe piano with 5 octaves
Post by: Yeong on October 11, 2011, 11:43:04 am
So, is the current version supports multi notes?
Title: Re: An Axe piano with 5 octaves
Post by: BalancedFury on October 11, 2011, 10:35:24 pm
I like these kind of things...
*DualBLDR downloads, and then rocks himself out of this world :trollface:
Title: Re: An Axe piano with 5 octaves
Post by: zero44 on June 14, 2012, 02:46:07 am
Hey,
I post it just to say you that the current downloadable version is the 1.1bêta, the final 1.0 will be finished in july.

Upcoming Features:

Please post a lot if you liked the flying donuts, 'cause I'll replace them by A, C#, F, etc. soon if nobody disagrees.

EDIT: I'll try too to adjust sound frequences, actually it's in 8-bit datas, I'll make high-quality 16-bit numbers =)