nathanRamaNoodles / Noodle-Synth

A User-friendly Arduino/Teensy Library to play RTTL/MIDI with infinite polyphonic notes; it has full control over volume, pitch, and music. No shields needed(Just a speaker).
https://create.arduino.cc/projecthub/nathan_ramanathan/play-music-without-delay-40e51b
MIT License
138 stars 14 forks source link

Port for 32 bit Teensy boards #6

Closed PaulStoffregen closed 6 years ago

PaulStoffregen commented 6 years ago

This lets your library work on Teensy 3.x boards. The port is pretty simple, using IntervalTimer to replace the timer2 interrupt and analogWrite to replace the direct PWM control.

nathanRamaNoodles commented 6 years ago

Hmm, seems interesting. Does this allow my library to work on other boards, or will I have to throw #ifdef everywhere? :D

PaulStoffregen commented 6 years ago

I'm sad to say more #ifdefs will be needed to support more types of boards. But usually it gets easier, since anyone wishing to support another board can see the places to edit and how others have worked.

Libraries which support direct access to hardware on many boards, like Firmata, Servo, IRRemote, OneWire, tend to add thin abstractions and move all the board-specific stuff to defines in a header file. Usually that sort of work makes sense when adding the 3rd or 4th board. Some authors just keep a bunch of #ifdef stuff in the code. It's really a matter of personal preference whether you feel the #ifdef stuff looks ugly and is worth the trouble of moving to a special header or some other abstraction.

I tried to keep this pull request as small as possible, but without rearranging any of your code.

nathanRamaNoodles commented 6 years ago

Well, I've heard and seen you in Arduino forms. I even remember referencing you when I had to debug problems when I just started Arduino in high school. And I know that you're pretty good with the Teensy. πŸ˜„ So, do you like this library? And did the example sketches sound good? I must admit, I could've used a 32-bit ARM Cortex, but I thought it was a nice challenge to use a simple 8-bit microcontroller that others could use. I'm not really that good with Timers and polyphonic synthesis, but I did well for the advanced functions, like skipTo()

PaulStoffregen commented 6 years ago

Must admit, I was pretty impressed when I heard your library's sound. I was expecting just 4 simple square waves. That's a pretty impressive amount of synthesis to squeeze into the limited processing power of Arduino Uno!

If you'd like some 32 bit Teensy boards to try, just say the word and I'll send you some hardware. So much more can be done with faster 32 bit hardware & more memory, especially on M4 with the DSP extensions.

nathanRamaNoodles commented 6 years ago

Uh, by "try" do you mean 35 bucks πŸ˜‚ or free?

PaulStoffregen commented 6 years ago

I'll send you some for free. :)

nathanRamaNoodles commented 6 years ago

Wow, really? Thanks, man. For once, I have witnessed engineers work for the love of making things(not for the sake of making money) :) So, where do I submit my address?

Also, can you play midi files from an SD card on the teensy?😍That is the one thing I can't figure out for my library. That's why I settled using RTTL.

PaulStoffregen commented 6 years ago

Email me directly, paul at pjrc dot com. And just to mentally prepare you, the free boards are leftovers that passed testing but have some minor cosmetic flaw which prevented them from being sold as normal retail products, so you can expect to see some scratches or discolored spots or other minor imperfections.

On MIDI files, I believe it should be possible but the format is not simple or set up to be read sequentially. So far, all I've done is use a program called Miditunes to convert the files into a giant C array. Like this:

https://github.com/PaulStoffregen/Audio/blob/master/examples/Synthesis/PlaySynthMusic/PlaySynthMusic.ino https://github.com/PaulStoffregen/Audio/blob/master/examples/Synthesis/PlaySynthMusic/william_tell_overture.c

Also, on the playing of musical notes, last year a group of students did a great project to play wavetables converted from soundfont2 format. It sounds really good.

https://github.com/TeensyAudio/Wavetable-Synthesis

Merging this into the main audio library has been on my todo list for some time. Seems like a ton of other stuff is always higher priority...

PaulStoffregen commented 6 years ago

Not going to merge this? :(

nathanRamaNoodles commented 6 years ago

I did merge it πŸ€”, check the Readme. It has teensy support. I added a bunch more features like volume control. Test it on your teensy and Make sure it works

On Sun, Sep 2, 2018, 8:38 PM Paul Stoffregen notifications@github.com wrote:

Not going to merge this? :(

β€” You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/nathanRamaNoodles/MusicWithoutDelay-LIbrary/pull/6#issuecomment-417977858, or mute the thread https://github.com/notifications/unsubscribe-auth/Ae8JnrZh5prm_RpompYwhsokk9vjabJeks5uXIgGgaJpZM4WQmNC .

nathanRamaNoodles commented 6 years ago

I didn't know I had to merge it πŸ˜…. I simply "copy and pasted it" Well I guess I learned something new πŸ˜„ Sorry for the miss communication.