Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 39

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

Hybrid View

  1. #1

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

    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

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    With a winbond-flash on the audioboard, the Teensy can play more than 10 (..never tried it :-) 44 Khz mono samples simultanoulsy.
    There's a library: https://github.com/FrankBoesing/Teen...romSerialFlash

    Pensive built an awesome device with it.
    https://forum.pjrc.com/threads/26493...read-Beatmaker

    Perhaps ask him how many channels are possible :-)

  3. #3
    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!

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,845
    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.

  5. #5
    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

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,845
    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.

  7. #7
    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

  8. #8
    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.

  9. #9
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Quote Originally Posted by PaulStoffregen View Post
    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.

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,845
    That link seems to be dead.

    I can tell you the largest chip that's been tested is Micron N25Q00AA. You can see the list of tested parts here:

    https://github.com/PaulStoffregen/SerialFlash

    Some time ago, Onehorse was talking about making a board with an even larger chip, when it becomes available.

  11. #11
    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...

  12. #12
    Senior Member onehorse's Avatar
    Join Date
    Apr 2014
    Location
    Danville, California
    Posts
    921
    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...

  13. #13
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,845
    Quote Originally Posted by thebigone View Post
    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....


    Quote Originally Posted by onehorse View Post
    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.

  14. #14
    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

  15. #15
    Junior Member
    Join Date
    Oct 2018
    Location
    France
    Posts
    8

    Smile

    Do you have any rough idea how long until the audio library will work with Serial Flash?
    Quote Originally Posted by PaulStoffregen View Post
    No, there's no reliable time estimate. But it ought to be within the next couple months....
    Hi Paul,
    I'm interested in playing music and sound simultaneously:
    I was quite stuck with Arduino... as far as I understand the system described here, I could use Teensy + SPI flash chip + Audio board? or it still requires some evolution of the library quoted above?
    Thanks

  16. #16
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    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.

  17. #17
    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 :-)

  18. #18
    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

  19. #19
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    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.

  20. #20
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    Quote Originally Posted by Pensive View Post
    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.

  21. #21
    Quote Originally Posted by Pensive View Post
    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.

  22. #22
    Quote Originally Posted by thebigone View Post
    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

  23. #23
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    Quote Originally Posted by thebigone View Post
    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?

  24. #24
    Senior Member Pensive's Avatar
    Join Date
    Aug 2014
    Location
    Basingstoke, UK
    Posts
    562
    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.

  25. #25
    Very nicely done! It sounds good, too! Congrats.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •