ghostintranslation
Well-known member
Hi,
I made a basic circuit with 4 multiplexers on A0 A1 A2 A3, and I coded an Audiostream class to sample those at audio frequency and be able to plug them to any other audio object. 8 inputs can be sampled at 44.1kHz each, 16 at 22.05kHz, and up to 32 at 11.025kHz.
This is part of a larger project for a Teensy 4.0 Eurorack modules base (actually v2 of it), for which it is useful to read signals up to 20kHz for FM for example.
I tried many different things, and that's the best I could do so far. I used a PIT timer and the ADC lib, but I couldn't take advantage of DMA, everything I tried didn't work for DMA, probably because I am not used to use it.
What the code does is it reads the 4 analog pins, then iterates the multiplexers, then read, then iterates... until I have 128 samples (or 64 or 32 when more than 8 inputs) for each input. The bottleneck is reading multiple pins "at the same time", but I'm almost sure someone will be able to add DMA or do something to improve and possibly get 44.1kHz on the 32 inputs.
Filtering can be set with a method so that for slower sampling frequency it smooth the signals better.
Here is a quick demo video:
https://www.youtube.com/watch?v=uRedUWVYY1Y
And here is the code:
https://gist.github.com/ghostintranslation/7804fd1ef46d85e38ad0f74df730480e
I'd be happy to hear from anyone that could increase the sampling frequency when more than 1 pin is read (more than 8 inputs)
I made a basic circuit with 4 multiplexers on A0 A1 A2 A3, and I coded an Audiostream class to sample those at audio frequency and be able to plug them to any other audio object. 8 inputs can be sampled at 44.1kHz each, 16 at 22.05kHz, and up to 32 at 11.025kHz.
This is part of a larger project for a Teensy 4.0 Eurorack modules base (actually v2 of it), for which it is useful to read signals up to 20kHz for FM for example.
I tried many different things, and that's the best I could do so far. I used a PIT timer and the ADC lib, but I couldn't take advantage of DMA, everything I tried didn't work for DMA, probably because I am not used to use it.
What the code does is it reads the 4 analog pins, then iterates the multiplexers, then read, then iterates... until I have 128 samples (or 64 or 32 when more than 8 inputs) for each input. The bottleneck is reading multiple pins "at the same time", but I'm almost sure someone will be able to add DMA or do something to improve and possibly get 44.1kHz on the 32 inputs.
Filtering can be set with a method so that for slower sampling frequency it smooth the signals better.
Here is a quick demo video:
https://www.youtube.com/watch?v=uRedUWVYY1Y
And here is the code:
https://gist.github.com/ghostintranslation/7804fd1ef46d85e38ad0f74df730480e
I'd be happy to hear from anyone that could increase the sampling frequency when more than 1 pin is read (more than 8 inputs)