I'm working on a project called "NoteMan". Basically, it allows you to write simple 1-channel audio tracks in TI-BASIC files and it will play them.

Here is an example of "Twinkle Twinkle Little Star":
Code:
"02C1,02C1,02G1,02G1,02A1,02A1,04G1,02F1,02F1,02E1,02E1,02D1,02D1,04C1,02G1,02G1,02F1,02F1,02E1,02E1,04D1,02G1,02G1,02F1,02F1,02E1,02E1,04D1,02C1,02C1,02G1,02G1,02A1,02A1,04G1,02F1,02F1,02E1,02E1,02D1,02D1,06C1"
Asm(prgmNOTEMAN)


Basically, each note is written like this:

Code:
##$#


The first two "##"s is how long you want the note to play. "00" doesn't do anything. "01" is pretty short. "02" is twice as long. "03" is three times as long as "01", and so on and so forth. You can also think of this as how many beats per note.

The "$" is the note. This can be A, B, C, D, E, F, or G. You can also write them in lowercase if you want to get the flat of it. Such as, "g" is "Gb" while "G" is just a regular G. There is no way to designate sharps. Just go to the next note and make it flat. That's the same thing.

The final "#" is your octave. Currently, there are three octaves. And they work like this:

Code:
C0
D0
E0
F0
G0
A0
B0
C1
D1
E1
F1
G1
A1
B1
C2
D2
E2
F2
G2
A2
B2


New octaves here start on C.

So, in conclusion, to, let's say, play a B flat on the second octave for four-times the length of a normal note, you would do this:

Code:
04b1


You also are supposed to separate the notes by commas. But you can separate them by anything.

The point of this project is simply for me to figure out how to use audio. But other people will be able to use it to easily create audio files on-calc, since you can write them in TI-BASIC.

I have most of it working and I'll post a download link sooner or later. And once it's finished I'll probably try to submit it to the archives.
A couple updates.
First of all, there seems to be a little problem where is the string is way too long, it will get glitchy. So you might want to break the song up into multiple strings.

I also added rests, such as "02R1" in there. "R"s are rests. You essentially write them like you would a note, except the last number doesn't matter. You need it there but it doesn't matter what it is. "02R1" just rests for 2 beats.

Also, I'm going to be releasing an Assembly library with this. This library will let you play songs from strings in Z80 Assembly rather than TI-BASIC and you will also be able to play individual notes simply by using something like "call playB1".

I also added another octave but it doesn't sound too great. The octaves are 0, 1, 2, and 3. C1 being middle-C.

Another important note is that if you set the length of your note to "0" then it will do the same thing as "01R1", so it will basically just rest a beat then continue. I'm not sure why you would make the length of your note 0 in the first place. I just made it do this because the alternative would be crashing. If you accidentally made your note have a length of 0 then this pause will help you find where the accident was made.

The songs you make seem to play ever so slightly faster and higher pitched on the Ti-84+ than the TI-84+CSE.
I don't think it's enough to make that big of a deal but it is noticeable.

Here is the download (when you go to the link, press Ctrl+S):
https://drive.google.com/file/d/0B4jc3uKzHHNXVWhERG5EcUVOY3M/edit?usp=sharing

Note that "NOTEMANC.8xp" is for the TI-84+CSE and "NOTEMAN.8xp" is for the TI-84+. I haven't tested this on the TI-84+SE, TI-83+SE, TI-83+, or TI-83.

Here's a couple songs you could try out:

Tetris
Code:
"02E2,01B1,01C2,02D2,01C2,01B1,02A1,01A1,01C2,02E2,01D2,01C2,03B1,01C2,02D2,02E2,02C2,02A1,01A1,01A1,01B1,01C2,03D2,01F2,02A2,01G2,01F2,03E2,01C2,02E2,01D2,01C2,02B1,01B1,01C2,02D2,02E2,02C2,02A1,04A1"
Asm(prgmNOTEMAN)

"04E2,04C2,04D2,04B1,04C2,04A1,04a1,02B1,02R1,04E2,04C2,04D2,04B1,02C2,02E2,04A2,08a2"
Asm(prgmNOTEMAN)

"02E2,01B1,01C2,02D2,01C2,01B1,02A1,01A1,01C2,02E2,01D2,01C2,03B1,01C2,02D2,02E2,02C2,02A1,01A1,01A1,01B1,01C2,03D2,01F2,02A2,01G2,01F2,03E2,01C2,02E2,01D2,01C2,02B1,01B1,01C2,02D2,02E2,02C2,02A1,04A1"
Asm(prgmNOTEMAN)


Gentle Jena (first couple lines)

Code:
"04C1,04F1,04b1,20F2,04A1,04b1,04F1,04C1,16D1,04b1,04F1,04C1,04e1,04D1,04b0,04C1,04F1,32b0,04C2,04F2,04b2,20F2,04F1,04b1,04F2,20b1,04C2,04F2,04b2,20F2,04F1,04b1,04F2,16e2"
Asm(prgmNOTEMAN)

"03R1,01b1,01C2,01D2,08C2,16F1,04R1,04F1,04e1,04D1,04e1,16b1,04R1,01b1,01C2,01D2,08C2,16F1,04C2,04F2,04e2,04D2,04e2,20b1"
Asm(prgmNOTEMAN)


A Slower version of Tetris:

Code:
"04E2,02B1,02C2,04D2,02C2,02B1,04A1,02A1,02C2,04E2,02D2,02C2,06B1,02C2,04D2,04E2,04C2,04A1,02A1,02A1,02B1,02C2,06D2,02F2,04A2,02G2,02F2,06E2,02C2,04E2,02D2,02C2,04B1,02B1,02C2,04D2,04E2,04C2,04A1,08A1"
Asm(prgmNOTEMAN)

"08E2,08C2,08D2,08B1,08C2,08A1,08a1,04B1,04R1,08E2,08C2,08D2,08B1,04C2,04E2,08A2,16a2"
Asm(prgmNOTEMAN)

"04E2,02B1,02C2,04D2,02C2,02B1,04A1,02A1,02C2,04E2,02D2,02C2,06B1,02C2,04D2,04E2,04C2,04A1,02A1,02A1,02B1,02C2,06D2,02F2,04A2,02G2,02F2,06E2,02C2,04E2,02D2,02C2,04B1,02B1,02C2,04D2,04E2,04C2,04A1,08A1"
Asm(prgmNOTEMAN)


Sorry if it doesn't sound completely in-key. I don't exactly have an ear for music.
I'm excited for this program, for it is one of the only programs to play music through the 84C, and it might inspire other programs that use songs.

amihart wrote:
First of all, there seems to be a little problem where is the string is way too long, it will get glitchy. So you might want to break the song up into multiple strings.
What does the glitch consist of?

I can't wait until the final version of this, but until then, I'll be using this program and some sheet music to transform my calculator into an ipod. Razz
FrozenFire49 wrote:
What does the glitch consist of?


It seems like the entire string isn't stored in Ans if it's too long. Like, it only stores part of it. The first two bytes that tell you the length of Ans will agree that the string is short even though it's supposed to be long. It basically cuts a lot of it off.

I guess Ans has a size limit?

Quote:
I can't wait until the final version of this, but until then, I'll be using this program and some sheet music to transform my calculator into an ipod. Razz


I'll continue working on it.
Note that this can also be used for programming games in TI-BASIC.
You can play a single note pretty quickly which can be used for sound effects in games (such as playing a little tone when the ball hits the paddle in a pong game).
The only limit to the size of Ans is free RAM. For various reasons, this limit is likely to be exceeded if the string you're manipulating is bigger than one-third to one-half the size of free RAM. If you exceed the free RAM limit, you should get an ERR message. Truncation is not a behavior the OS should exhibit unless you specifically ask for it via sub().
DrDnar wrote:
The only limit to the size of Ans is free RAM. For various reasons, this limit is likely to be exceeded if the string you're manipulating is bigger than one-third to one-half the size of free RAM. If you exceed the free RAM limit, you should get an ERR message. Truncation is not a behavior the OS should exhibit unless you specifically ask for it via sub().


Thanks for the info. I'll look into it and see if I can figure out what is the issue.
Okay, I found the problem. It was simply an overflow error.
It was a simple fix.
I also added to where if you do not have lowercase already enabled (which is required for sharps and flats) then you can disable/enable lowercase by passing a 1 into the program.

Such as:
Code:
1:Asm(prgmNOTEMAN)


That will enable lowercase if it's disabled and disable lowercase if it's enabled.

Since I fixed the glitch before, you can now do strings much longer.
However, the program only allocates 3000 B of RAM for your songs. I could increase this number but I don't want my program to take up too much RAM. 3000 B of RAM is about 600 notes. Try to keep your program below 600 notes. It may crash if it's above 600 notes.

Here's Tetris again but all together:

Code:
"02E2,01B1,01C2,02D2,01C2,01B1,02A1,01A1,01C2,02E2,01D2,01C2,03B1,01C2,02D2,02E2,02C2,02A1,01A1,01A1,01B1,01C2,03D2,01F2,02A2,01G2,01F2,03E2,01C2,02E2,01D2,01C2,02B1,01B1,01C2,02D2,02E2,02C2,02A1,02A1,02R1,04E2,04C2,04D2,04B1,04C2,04A1,04a1,02B1,02R1,04E2,04C2,04D2,04B1,02C2,02E2,04A2,08a2,02E2,01B1,01C2,02D2,01C2,01B1,02A1,01A1,01C2,02E2,01D2,01C2,03B1,01C2,02D2,02E2,02C2,02A1,01A1,01A1,01B1,01C2,03D2,01F2,02A2,01G2,01F2,03E2,01C2,02E2,01D2,01C2,02B1,01B1,01C2,02D2,02E2,02C2,02A1,04A1"
Asm(prgmNOTEMAN)


Here the download for the update of NOTEMAN for the TI-84+CSE:
https://drive.google.com/file/d/0B4jc3uKzHHNXczNiU3dTTmgwYzA/edit?usp=sharing
Thanks for the update.

I know that currently that the program with the music needs to pause for the the music to play. Do you think it's possible for to reconfigure this somehow to play looping background music for games, for example the Tetris music for a Tetris game?
FrozenFire49 wrote:
Thanks for the update.

I know that currently that the program with the music needs to pause for the the music to play. Do you think it's possible for to reconfigure this somehow to play looping background music for games, for example the Tetris music for a Tetris game?


I honestly have no clue how to do that. :/
A couple more things I'm adding:

I've changed it from passing a 1 into it to passing a 0 into it to turn on/off lowercase. Why? Because now if you pass a number into it and not a string, it will play that tone for one beat. This way you can play your own custom notes instead of using the notes if you so wish. The custom notes are specified by inputting a wavelength.

So something like:
Code:
50:Asm(prgmNOTEMAN)
This will play a really high-pitched tone, while something like:
Code:
2500:Asm(prgmNOTEMAN)
This gets you a really low tone.

I'm also fixing a few bugs and stuff. Once this is finished I'll upload another complete package for the TI-84+CSE, TI-84+, and the source code.

I'll also be uploading the library to use this in Z80 programs.
Do you mind if I use this program to add some sound effects to my games, while giving you the credit for NoteMan?
FrozenFire49 wrote:
Do you mind if I use this program to add some sound effects to my games, while giving you the credit for NoteMan?


Sure, that's what I made it for.


Also, I've finished enough of it that I'm going to be putting it in the archives. I finished the library of it for Z80 assembly as well. You can download it here now or wait until I upload it to the archives.


Here's a quick reference on how doing things in TI-BASIC differ from Z80 Assembly:

Play a Song (TI-BASIC):

Code:
"04C1,04C1,04G1,04G1,04A1,04A1,08G1"
Asm(prgmNOTEMAN)


Play a Song (Z80 Assembly):

Code:
include "ti84pluscse.inc"
org userMem-2
db $EF, $69

start:
   ld hl, song   
   call playSong
   ret

song:
   db "04C1,04C1,04G1,04G1,04A1,04A1,08G1",0

include "noteman.inc"


Play a custom tone from a wavelength (TI-BASIC):

Code:
750:Asm(prgmNOTEMAN)


Play a custom tone from a wavelength (Z80 Assembly):

Code:
include "ti84pluscse.inc"
org userMem-2
db $EF, $69

start:
   ld hl, 750
   call getDuration
   call play
   ret

include "noteman.inc"
I made a video demonstrating NoteMan if anyone wants to see it in use:

Wierd, I posted here, then went to log on and couldn't. Long story short my account was deleted, since I made a new one with the exact same info!
Also, when my headphones (and earbuds) are plugged in, I cannot interact
EDIT: sometimes, not always!
Can you make an MP3 convertor for this?

Also, if that is possible, can I finish my Music app and use this?
the Z80 assembly sections get converted into hex and then run?
If I wanted to modify this to do saw waves instead of square (or choose per note) or choose from a volume level of 1-10 (aliased, no 1.5), how would I do that
NOTEMAN doesn't show up in the edit category, so I know I'll have to edit on TI Data Editor
But what and how do I edit?
solarsoftware wrote:
Can you make an MP3 convertor for this?


There is no way that this could be used to play (converted) mp3s. This program plays a series of notes, while mp3 is compressed raw audio data.
One thing that would be awesome would be a different pitch and/or volume on L and R
Alex_Poulsen wrote:
If I wanted to modify this to do saw waves instead of square (or choose per note) or choose from a volume level of 1-10 (aliased, no 1.5), how would I do that
NOTEMAN doesn't show up in the edit category, so I know I'll have to edit on TI Data Editor
But what and how do I edit?


your going to need the source code (which you have to get from the author), and an understanding of assembly programming.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement