Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.

Would you consider addding sound to your program/game?
Yes
 75%  [ 9 ]
No
 0%  [ 0 ]
Maybe with more instrument/sound options (multi-channel, etc.)
 25%  [ 3 ]
Total Votes : 12

I have created a USB sound card system for the TI-84+ CE that uses the serial drivers to communicate with an Arduino. It supports sending square wave tones as well as PCM audio samples. To send frequencies, the calculator simply sends 0xFF and then a 16-bit value (little endian) that specifies the frequency, and the Arduino plays it until the next tone is sent. Sending a frequency of 0 stops the audio.

To send PCM audio, the calculator sends 0xFFFEFE, which triggers it to switch to PCM mode. It will then send a 0 to get a sync signal. Once the sync is received the audio data stream is sent, though it will have to be regulated on the calculator. You must send over only unsigned 8-bit audio at 8000 Hz, as this is what the Arduino is expecting.

To use this, you will need a TI-84+ CE (obviously), an Arduino (I used an Uno but others should work), some sort of speaker you can plug into the Arduino, a USB power supply to plug into the Arduino headers (I used a USB->Serial adapter which provides 5v), and a USB OTG cable to connect the Arduino to the calculator. You can get the source code here: https://github.com/MCJack123/ticesnd.

To run one of the examples, cd to the example, make, and send to the calculator. Next, copy the contents of src/arduino/soundcard.c into a new Arduino sketch and send the sketch to the Arduino. Lastly, connect the speaker to pins 11 & ground, the calculator USB into the Arduino USB, and a 5v power source into Vin/ground or a 9v power supply to the power in jack (if applicable) on the Arduino (required as the calculator doesn't supply enough current). You can use playTone(tone, length) in your own programs to play sound. You can also play PCM audio by running switchToPCM() and then sendPCMAudio(data, size). I hope to turn this into a full audio player in the future.

See README.md on GitHub for more information on how to use the library.

Here is the demo program playing "Mary Had A Little Lamb" with the tone mode:



Also, here is a PCM demo with the first 8 seconds of the Portal radio loop:

My god ! its a great job and it give very good sound.
Congratulations and thank you for sharing this great project JackMacWindows

There are several members who work on usb copnnection, maybe you could talk with them to exchange knowledge. (and maybe build a kind of "protocol" to associate some low frequency at some orders (for exemple specify a tone duration or a "repeat note", some "fx sound" controlled by arduino)

You can also use your program to control a lot of other interface, once the link between TI and Arduino is done, everything is open : IR remote, engine control (with optocoplers to avoid back current), connected objects...micro sd ram interface...
I've created a sound API that you can include in your programs here: moved. Just add them into your source directory, include and build. Make sure that usbserial.h is next to sound.c.
Hey that's pretty darn cool! Much better sound than my monstrosity I based off of this topic (which is about sound on a calculator, you many want to link this thread over on that topic!). I'll get out my Arduino Uno and see if I can create a song!
Looks great!
Let me know if you have any feedback about the serial library, as it is still under development.
Update: I'm currently working on PCM audio, and I've got the main Arduino sound card code working. It currently uses unsigned 8-bit audio at 8000 Hz, though it may be possible to bump the frequency up to 11025 Hz. The problem I am facing is that the card doesn't control the timings of the stream, so the calculator has to send the bytes individually. It seems like the serial library doesn't send things quickly enough (monitoring the Tx line only shows a byte or two each second). I could send the audio byte by byte, but that would require Ás accuracy while tice.h only provides ms accuracy. My current approach is to send chunks of bytes, but eventually it starts sending too fast. I'm hoping to get PCM audio working by next week. For now, here's the code I have so far (moved). The Arduino code works fine, but the calculator code for sending PCM is not working. The code base is (mostly) backwards-compatible, so earlier code will work with the newer sound card firmware.

Also, commandblockguy, would it be possible to speed up the write functions a bit? It seems they may be too slow for audio transfer.
Pings with @ don't work here, but I'm monitoring this thread anyways.
It would be hard to speed up the srl_Write function, but I could make a non-blocking version which does not wait for a transfer to complete.
srl_Write starts one USB transfer per call, so it's significantly faster to send all bytes at once than one at a time.
If you are running into issues with sending too many bytes, you might be able to make a counter for the number of bytes have already been sent, then repeatedly send timer * rate - counter bytes.
wow. nice project. love the snap circuits setup.
Updated the code and put it into a real GitHub repo. PCM is now fully working thanks to adding a sync signal! Very Happy I edited the main post with the new information.
Thank you a lot for this project JackMacWindows.
I have added some multi-channel audio support with the help of an extra Raspberry Pi. PCM audio currently isn't working but I hope to fix that soon. If you want to try it out, you can compile and run it from the source on the GitHub repo. Instructions to build the Pi code is at the top of the source. Here is a demo using two channels:

It's totally crazy !
With 16 channels !!!
Excellent work JackMacWindows, excellent work!
Ooooh very nice! I've never been so hyped to hear Mary had a little lamb! Laughing
If we want to have the multi channel support, do we need both an Uno and a Pi or could we just use one or the other? Great work so far!
The Arduino is only being used as a serial adapter, so it's not strictly necessary if you have another serial adapter that will work with the serial drivers. (The Arduino is just running on a blank sketch.)
  
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 1
» All times are GMT - 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