Teensy 3.1 + Audio Board polyphony - how many is too many?

Status
Not open for further replies.

thebigone

Active member
Hello all,

I am hoping to make an electric drum kit based on the Teensy 3.1 + Audio board. This is rev 2 of a project I made a few years back: http://drummaster.digitalcave.ca/drummaster/. The original version ran on an Arduino and communicated with a computer for playback. Now, I want to make it completely self contained.

The analog stuff is easy and I have plans mostly completed for all that. What I am not sure about is the abilities of the teensy.

Basically, the workflow goes like this:
1) Hit a pad
2) Peak detection circuit to hold analog value; pass this value through to the teensy's ADC via an analog MUX
3) Teensy reads value, looks for the corresponding raw audio file (or wav file, but I think raw is faster), and starts to play it.

This is all simple enough... the issues start when you have multiple sounds playing at once.

Obviously some sounds are longer than others (a ride cymbal will play for easily 10+ seconds, whereas a snare drum will be less than a second).

In the computer-based implementation, I used multiple threads to play each sound, and kept track of how many sounds were currently active. If there were more simultaneous sounds than some limit (I think it was 16, but don't remember offhand). If there were more than this number of sounds playing, I would stop the one which has been playing the longest.

Now I realize that a teensy is not as powerful as a computer, so 16 sound polyphony is probably not feasible. However, how many samples *can* I expect to play back concurrently, when streaming off an SD card? (Assume for the sake of argument that I have the best SanDisk card that money can buy). Is 8 achievable? 6? I don't need 16, but I don't think that i can go lower than about 6 - 8 before you can audibly hear the sounds cutting out. More is obviously better.

I would be handling the task of stopping sounds manually if there are too many playing at once.

Anyway, I thought that I would get a feel for the hardware capabilities before I purchased anything... thanks for any advice that the community may have!

Cheers
 
Definitely put the short sounds into the internal program memory. Playing from program memory has very low overhead.

Playing from SD card has a lot of overhead. Even the best Sandisk cards have a pretty long lag from requesting the sector until they actually start sending the data. Currently the SD library only buffers 1 sector. There's a new experimental SD library in development with a multi-sector cache, but it still buffers only 1 sector per file. It'll give you better performance, but won't work any miracles (like a conventional operating system can cache gigabytes of data in RAM).

The Serial flash chips are the best off-chip storage. They have extremely low latency. Theoretically, such a chip ought to be able to support about 25 simultaneous streams. The practical limit is probably lower, but so far little testing has been done to figure out exactly where that limit really is.
 
Nice... it looks like he is getting "8 to 9 44Khz mono samples running at the same time", which is perfectly acceptable for my needs, when using the SPI memory add-on. I may have to make the jump... :)

Thanks, Frank!
 
Thanks Paul. I will have to look at the samples I am using currently, but I am pretty sure that 16MB should be sufficient for a single set (e.g. acoustic, electric, whatever). When changing sets, you could read from a (slow) SD card onto the SPI flash; when playing the sounds they would be read directly from the SPI flash.

I'll definitely look into this further, but I think that it may be the answer... Thanks, Paul, for the comments and for helping the community at large.

Cheers
 
Eventually the audio library will use the SerialFlash library to access those chips. It supports the larger chips, which currently go up to 128 Mbyte/sec.

While the SPI flash chips have low latency and impressive read performance, they're fairly slow to erase and write. Fully erasing and rewriting a 16 Mbyte chip could take over a minute. It's certainly slow enough that you'd want to design some sort of progress indicator, so it doesn't seem like your board has crashed during the lengthy time needed to erase and write.
 
It would be OK for switching sets to take a bit of time... I am planning to have an HD44780 display on board, so showing a progress bar is no problem.

As far as size goes, it looks like this is the largest chip that would be supported?

Cheers
 
OK cool. The chip I was trying to link to was the Winbond W25Q256FV, which is listed as supported.

The Micron N25Q00AA would be very nice (I would have more than enough room for anything that I wanted to put on it), but it would not fit on the audio breakout board. Although perhaps that is not a problem anyway, as I would be making my own PCB for the analog circuitry, and could put the larger chip on there. Hmmmm...
 
Do you have any rough idea how long until the audio library will work with Serial Flash? I do realize there are third party options available today, so there are ways around the current limitations, but it would be interesting to know if the planned timeframe was weeks vs months vs years.
 
Some time ago, Onehorse was talking about making a board with an even larger chip

I assembled a couple of the Micron N25Q00AA chips on the board I designed but wasn't able to get them to work. It's possible I need to solder headers onto the board instead of using clip on jumpers, but I sort of hit a wall there and stopped. I was hoping to get some Macronix SPI flash memory chips since they have the one CS an very large memories, 2 Gbits and maybe even 4 Gbits IIRC, but the rep who promised to get me samples never came through.

I hope to get back on this path soon...
 
Do you have any rough idea how long until the audio library will work with Serial Flash?

No, there's no reliable time estimate. But it ought to be within the next couple months....


I assembled a couple of the Micron N25Q00AA chips on the board I designed but wasn't able to get them to work. It's possible I need to solder headers onto the board instead of using clip on jumpers, but I sort of hit a wall there and stopped.

I tested that same chip with the 16 pin package. It definitely does work. I used a little adaptor PCB soldered on top of a Teensy, so the wire length was under 2 inches.

I was hoping to get some Macronix SPI flash memory chips since they have the one CS an very large memories, 2 Gbits and maybe even 4 Gbits IIRC, but the rep who promised to get me samples never came through.

I'd like to test those chips with the library, especially ones more than 1 Gbit... but not enough to go through the hassle of the Macronix rep.
 
Thanks all,

I have looked at my samples, and while I will have to reduce the number of samples slightly (for instance, currently I have different samples for different velocity strikes, and in some cases have upwards of 30 different samples for a single drum; this is obviously excessive, and most of the samples are indistinguishable from the others), it looks like I can quite easily fit a complete set into 16MB. For instance, a set of samples that I have for an acoustic set can fit in about 9MB, so I even have some room for picking more samples if needed.

(And yes there are larger chips, but they have a different footprint and are more expensive; if in the future I find that I need more space I can always expand the memory at that time).

It looks like I will be going ahead with the Teensy... I'll be sure to post my results back here when I have something to report.

Cheers
 
Eventually the audio library will use the SerialFlash library to access those chips. It supports the larger chips, which currently go up to 128 Mbyte/sec.

Paul , you're writing a new version ? I do not care , but it would be good to know , because in this case I would not upgrade my version (waste of time). There have been some demands .

The other option would be to tell me your plans/ideas and i could integrate them into my existing lib and do a pullrequest.
 
Using Frank B's code, I was at about 90% CPU while mashing 16 buttons all at once, each one playing a different sample @ 44.1Khz mono from flash, with envelopes on each button.

This was all while updating an LCD screen, and interfacing the buttons through a PS/2 Keyboard library.

So in practical terms, a polyphony of 10 is a good reserved design spec, which will be easily achieved even with some synth sounds running.

If you read from an SDCard instead of flash, even with a good card the polyphony will drop dramatically. Avoid where possible.


If you intend to add 808 or 909 sounds the original samples are tiny and will probably fit in sketch ram, but you'll need to code a bitdepth upscaler from the original 10 bit (or was it 9bit?) audio.
 
Well, I made the jump and ordered the Teensy + audio board, and will be making a Digikey order shortly with the memory chips and other components needed for my design. I'll post back once I start to make some progress (probably won't be for another month or so given the summer busy season).

Thanks to all for your help, and I look forward to getting into the wonderful world of Teensy :)
 
In case anyone finds this thread later on, I have (more or less) finished the project. Details, videos, schematics, source code, etc can be found at https://hackaday.io/project/6881-drum-master (and eventually a distilled version with just the best information will be at http://drummaster.digitalcave.ca, although this is still a WIP as of the time of this writing). In short, the Teensy has worked beautifully. Thanks to Paul and the rest of you for all the help and direction!

Cheers
 
Cracking project! Probably the best use of the audio board I've seen to date.

It's amazing what one person can build with a bit of ingenuity and a quality software/hardware stack as a foundation.

Well played sir :)

I will need to take a closer look at your peak detection solution for the piezo :) sounds neat.
 
I have seen and noted your non-commercial license and will not utilise your solution.

Sorry, where are you looking? I generally pick non restrictive licenses for my work unless modifying an existing (restrictively licensed) design. If I have listed a non commercial license on work I had created from scratch, that is incorrect and I will fix it.
 
Sorry, where are you looking? I generally pick non restrictive licenses for my work unless modifying an existing (restrictively licensed) design. If I have listed a non commercial license on work I had created from scratch, that is incorrect and I will fix it.

Ahh, I think I found it - on the drummaster.digitalcave.ca website. That site is old and is in the process of undergoing major changes, but I missed the license text; it is now changed to attribution / share alike. Hope this works better for you :)

Cheers
 
Ahh, I think I found it - on the drummaster.digitalcave.ca website. That site is old and is in the process of undergoing major changes, but I missed the license text; it is now changed to attribution / share alike. Hope this works better for you :)

Cheers

Thank you! I don't want to be inspired by something i'm not allowed to be inspired by!!! :)

I need to get a piezo working - I've not connected it up yet, but i also can't afford too many clock ticks doing software fudges.

I'm sure my dad will understand your schematics better than I do. :) I can follow it and build it but I don't have a _feel_ for the electronics logic behind it, if you will. It will come with time, I'm sure.

is the second amplification stage still required if you plug straight into a teensy pin? how low is the signal?
 
I'm using this one:
https://www.sparkfun.com/products/9196

Apparently i need to bring the voltage down from a peak of 30 instead; Still AC, though I believe? It doesn't say but the nature of the vibration leads me to believe so.


I'm not so sure this piezo is similiar enough to yours for your circuit to work out of the box.
 
Thank you! I don't want to be inspired by something i'm not allowed to be inspired by!!! :)

I need to get a piezo working - I've not connected it up yet, but i also can't afford too many clock ticks doing software fudges.

I'm sure my dad will understand your schematics better than I do. :) I can follow it and build it but I don't have a _feel_ for the electronics logic behind it, if you will. It will come with time, I'm sure.

is the second amplification stage still required if you plug straight into a teensy pin? how low is the signal?

If not amplification, you will probably want some sort of impedance matching there. If you look at the schematic http://drummaster.digitalcave.ca/drummaster/img/schematic_rev2.pdf, the output of the peak detection bit is at the *_D labels, e.g. HP_D. If you were to attach an ADC pin directly at that point, you may get a faster falloff from peak voltage (since the ADC pin would be draining a (very small) amount of current). By buffering it with another op amp (either at unity gain or with some amplification), you are providing the ADC a low impedance output to read from.

As far as the voltage level is concerned, the voltage at point HP_D will be the actual peak voltage, up to the op amp rail voltage minus the voltage drop of the diode. So in my system, I am using rail to rail op amps at 3.3v, with a standard diode which has a voltage drop of about 0.6V, so I have a peak value of about 2.7V at that point. I seem to recall that in practice it is a bit less than that. The amplification after that is nice (especially for calibration; I find that some of my pads are more sensitive than others; this allows me to normalize them), but not strictly needed.

If you have not already done so, give Falstad's circuit simulator a shot. It is not perfect as far as simulators go (I understand that Spice, etc are more accurate), but the simplicity of Falstad's sim makes it perfect for throwing quick things together and seeing what happens. When designing the peak detection circuit, I used this simulator heavily (and in fact there is a peak detection sample in the examples folder somewhere).
 
Status
Not open for further replies.
Back
Top