Audio For Teensy3 - What Features Would You Want?

Status
Not open for further replies.
Nice stuff, Paul! I'd like to say my word, also, about some features that maybe useful to a lot of people, for sure :)
An SD card connector doesn't seem that necessary, and it also takes a lot of board space which could, although it could become useful if someone wants to implement some kind of wavetable synthesizer, so I'll keep it. Regarding some library aspects, I'd say that USB support is another important aspect to consider; I've got some basic USB audio stuff to work, but my objective is to get a board just like yours to be fully controlled via USB. Reading through the USB audio specs, I've seen that there''s a lot of things, that should be implement to make a fully working 2 in 2 out interface with digital volume control, that need to work strictly together with the I2S software; and probably, developing both aspects together might help. Or at least, the whole I2S audio library should keep some sort of backdoors to render the developing of a latter USB library faster and/or easier. I'm already doing some stuff, as I said, and I need to do it anyway :D so if you need any spare hand I'm here! :)
 
Integrating USB audio is something I'd like to do at some point, but definitely not until there's at least a first alpha release with basic functionality.
 
Cool, seems totally legit! You know, I've been developing my own ADC/DAC PCB some months ago, and I still have to build it, but the fact that hyple has done a nice I2S handler library and the fact that getting USB stuff to work the right way is a very daunting task, well, these things led me to start to work on the USB part before doing the I2S part, rest assured that developing a good working prototype is not easy nor cheap. I'm really curious about this audio library, and boards as well!
 
5) I'm really tempted to use this thing as neat little lo-fi synthesizer now. That could be really, really fun. Teensynth. (Find some old SID chips and let me make a ridiculous Commodore 64 chiptune synth, Paul! :p)

I believe you'll be pleasantly surprised by the synth capabilities possible using the ARM Cortex-M4 processor. ;)
 
Having the Line I/O comply with PC audio brackets is a great idea, it saves space and does not introduce another arbitrarily defined standard. So from the board drawing I see there will be stereo line in plus a mic in and stereo line out plus headphones out. Suggestion/Question: Could the stereo line output and the Headphone output be merged? Electrically these have about the same typical voltage level (provided you use low impedance, high sensitivity phones, which is common for in ears) and only differ in the amount of current they can provide (or how low a load impedance is allowed) before distortion increases significantly.
Could you design the board area where the optional pot goes in a way that allows a rotary encoder in the same spot as an alternative? I'd prefer capacitor coupling for the headphone instead of a virtual ground, but i guess the required caps would be too large? Btw, Paul, all this is meant as constructive criticism, i'm just lacking english skills to always express myself politely :cool:
 
Could the stereo line output and the Headphone output be merged? Electrically these have about the same typical voltage level (provided you use low impedance, high sensitivity phones, which is common for in ears) and only differ in the amount of current they can provide (or how low a load impedance is allowed) before distortion increases significantly.

They're not the same, electrically speaking.

The line level outputs are capacitively coupled, so they can be referenced to system ground. The headphone out uses a virtual ground to avoid large capacitors. They must not be connected to another system which expect a ground-referenced AC signal.

The line level out is also probably a quieter and higher quality signal. Even though 33 ohms isn't a huge load, power amplifiers do add some noise and some distortion. This board uses a low power and low cost codec, so the signal quality certainly isn't "audiophile", but probably is comparable to the quality of a portable consumer CD or MP3 player. For people who want a cleaner signal, at least as good as this Codec can do, getting it right from the DAC before going through the headphone amp is probably a good approach.

Edit: the other reason to bring out both is based on the pretty strong consensus in the feedback so far, to make sure every signal at least comes to solder pads.

Could you design the board area where the optional pot goes in a way that allows a rotary encoder in the same spot as an alternative?

If there's a rotary encoder which fits into that small space, I could probably do this. The only rotary encoders I have are much larger.

Do you have any specific parts in mind? A link to the datasheet with mechanical drawing or recommended PCB footprint would be helpful.


I'd prefer capacitor coupling for the headphone instead of a virtual ground, but i guess the required caps would be too large?

Well, it certainly is possible All you have to do is add the capacitors in series with the 2 signals, and then you can use system ground instead of the virtual ground. Those caps aren't terribly expensive, but they do add to the board size because they're physically pretty large.
 
Last edited:
this is more of a follow-up question than a feature request, as i'm not very knowledgable about hardware capabilities and requirements - but since you've mentioned pd and max/msp in connection with the audio api, i was wondering what exactly will/will not be possible in this direction: so i assume the idea is to have a/o come up with classes analogous to "objects" such as [osc~], [phasor~] and the like, which i trust will work just fine but what about, say, objects like [tabwrite~], [delwrite~] or [susloop~] or, well, anything depending on more or less sizeable buffers. with a 16KB RAM, if i see it right, at 16bit 44.1khz stereo everything will be limited to buffer sizes << 0.1 sec, which isn't very much.

well, my question then: is writing/reading to SPI/SDcard actually fast enough to compensate? or will all that just be very tricky w/o some fast external memory, which, considering the pin count of such chips, doesn't seem to be an option? also, as i've seen people using spi rather than parallel SRAM with arduino (microchip 23LC1024), i'm guessing the usage (no fsmc) and performance of such chips can't be much superior to microSD?
 
Last edited:
This all sounds great. I'm so glad audio.h is on the way.
The only thing I might like to see is a pad directly on the line inputs to act as a AC coupled input. That way it can be used for CV or just high res pots and such.
 
I must confess, I've been targeting only 44.1 kHz sample rate, which has been working very well so far. Admittedly, "so far" is at an early stage of development...

The sample rates and bit depths I have seen used in practice are:

22.05/16 or even 22.05/12 (lofi, but better than PWM)
44.1/16 (CD and rips therof, consumer audio recording)
48/24 (DAT, home studio)
88.2/x (no-one)
96/24 (home studio, pro studio)
192/24 (audiophiles with no clue)

It would be really nice to be able to do 96/24 and if not, 48/24 (just because the brickwall antialias filter has a bit more room between 20k and 24k then it does between 20k and 22.05k so can have a better behaved phase response).
 
Last edited:
This all sounds great. I'm so glad audio.h is on the way.
The only thing I might like to see is a pad directly on the line inputs to act as a AC coupled input. That way it can be used for CV or just high res pots and such.

DC coupled?
 
I believe you'll be pleasantly surprised by the synth capabilities possible using the ARM Cortex-M4 processor. ;)

I believe that lo-fi should be a "because I want to" rather than a "because its the only option, so let's pretend its cool".
A direct digital synthesis oscillator (using the audio ADC for control voltage, including audio-rate control like FM; and the DAC for audio output) is a fairly obvious application here.
 
so i assume the idea is to have a/o come up with classes analogous to "objects" such as [osc~], [phasor~] and the like, which i trust will work just fine but what about, say, objects like [tabwrite~], [delwrite~] or [susloop~] or, well, anything depending on more or less sizeable buffers. with a 16KB RAM, if i see it right, at 16bit 44.1khz stereo everything will be limited to buffer sizes << 0.1 sec, which isn't very much.

Yes, that's correct, the small RAM does limit this to pretty much only real-time stuff without big buffers. Limited reverb might be possible, but certainly any sort of substantial delay just isn't possible without much more memory.

The reality is a good portion of the 16K isn't really available. About 2-3K is needed for USB buffers. I might make a special "serial monitor only" USB type that uses minimal buffering, to free up memory. About 1-4K is needed for audio block buffers. The I2S output object needs 512 bytes dedicated DMA buffer memory.


well, my question then: is writing/reading to SPI/SDcard actually fast enough to compensate? or will all that just be very tricky w/o some fast external memory, which, considering the pin count of such chips, doesn't seem to be an option? also, as i've seen people using spi rather than parallel SRAM with arduino (microchip 23LC1024), i'm guessing the usage (no fsmc) and performance of such chips can't be much superior to microSD?

So far, I haven't tried writing to the SD card. The performance really depends heavily on the card, because not all SD cards are created equal. But I would be surprised if any SD card can give good simultaneous read performance while also writing.

That little 23LC1024 chip looks very interesting. Of course, it's only about 1.4 seconds of audio, but the writing process has no delay, so it should be pretty feasible to build objects like [delwrite~] using it.


It would be really nice to be able to do 90/24 and if not, 48/24 (just because the brickwall antialias filter has a bit more room between 20k and 24k then it does between 20k and 22.05k so can have a better behaved phase response).

48 kHz is looking unlikely, at least using I2S that keeps the same rate synchronous with the processor's clock, because Freescale's circuitry just can't generate a 48 kHz MCLK without massive jitter. Perhaps someone will develop an async I2S object? Hyple's library has the necessary I2S code. The difficult part is "just" how to integrate it with this not-yet-published audio API stuff. Later this year or early next year, after a least few alpha or beta releases, would be the time to consider that.

On anti-alias filtering, most I2S DACs add interpolated samples, so all the aliasing is at much higher frequencies. One I have my eye on for an "audiophile interface" board is the Wolfson WM8740, which adds 8X interpolation.

The API will be designed for 16 bit samples. I'm sure the desire for 24 or more bits is going to become a frequently asked question. Maybe next year (or perhaps sooner if anyone really wants to take this on), it might be possible to build a 24 bit version and implement at least some of the objects. But there are 2 pretty big advantages to working with "only" 16 bits. First, RAM is limited. Usually anything bigger than 16 gets stored in 32 bits, which will burn up the limited RAM twice as fast. The second nice advantage of 16 bits is the Cortex-M4's DSP/SIMD instructions (which are designed for pairs of 16 bit integers packed into 32 bit words). At least initially I'm focusing on the system-level design, and in fact I'm just now starting to look into an efficient way to report CPU usage. Later I intend to work on optimizing some of the objects using SIMD instructions.

I'm sure we're going to see people regularly asking for 24 bit audio, thinking it would somehow sound better. Maybe it would? If enough people really, really want this, I'll probably work on it eventually. In the meantime, I'm probably going to adapt the I2S code to use 32 bit words (using only the first 16 bits), partly so at least the capability will be there for anyone who wants to take on 24 bits, but mostly because nearly all DACs show this in the timing diagrams.

A direct digital synthesis oscillator (using the audio ADC for control voltage, including audio-rate control like FM; and the DAC for audio output) is a fairly obvious application here.

I already have a DDS sine wave object. Will soon work on a version where each phase accumulator increment is based on the samples from another audio stream, instead of a constant.

The only thing I might like to see is a pad directly on the line inputs to act as a DC coupled input.

The ability to use the 16 bit analog input for pots or control voltages sounds pretty nice, but I'm not quite sure how it could work in the context of these Codec chips. They're really designed for only AC coupled signals.

The chip runs from a single 3.3 volt supply. Internally, it generates some DC bias voltage. That DC level probably varies with temperature and maybe other factors. You can be pretty sure the level is approximately 1.6 volts, but of course it's not really well known. For AC coupling, the specific DC bias doesn't matter. The chip just weakly couples that DC level to the input, assuming the source has infinite impedance at DC (a series capacitor), and of course the analog circuitry in the chip's sigma-delta modulator uses the same bias level.

There is a pin for filtering the chip's bias voltage. Normally you're supposed to connect a capacitor between that pin and analog ground, but nothing else. That pin may or may not be the actual DC reference for zero. It might be buffered inside the chip before weakly driving those inputs, where the buffer might add an offset voltage (which isn't an error for AC signals if the signals and the modulator inside the chip see the same voltage). Even if that pin is an accurate reference for DC zero, it's probably not a low impedance. Using it without buffering might wreck the ADC's performance.

So while I think it'd be pretty awesome to be able to use the ADC for non-audio DC coupled signals, I just don't see a realistic way for that to work well, in the context of these Codec chips designed only for audio signals. If anyone has any ideas or could point to some projects that have done this successfully, I'm certainly willing to consider it.
 
[...] I would be surprised if any SD card can give good simultaneous read performance while also writing.

That little 23LC1024 chip looks very interesting. Of course, it's only about 1.4 seconds of audio, but the writing process has no delay, so it should be pretty feasible to build objects like [delwrite~] using it.

thanks for clarifying. i must admit, i haven't come across anyone actually using those 23LC1024 chips in an audio type application, but if it could be done ... 1.4 seconds doesn't sound bad at all. certainly it would increase the range of possibilities. rudimentary granular synthesis also comes to mind, for example; or karplus-strong (though in some form that should be doable anyhow).

i realize it's a bit pointless without having established first that these chips actually can pull it off, but in principle it should be perfectly possible to somewhere fit another soic-8 chip on the SPI lines going to the SD card, no? either as an alternative or possibly even with it's own chip select?
 
ps: as to DC coupling, the openmusiclabs shield is DC-coupled on both inputs and outputs, as far as i know (well, that's what their website says). i'm not sure about the ADC end of things, but i'd figure that people in need of generating DC / subaudio signals will be better served with a voltage DAC. control voltages, for example, which is the most obvious musical application, tend to be 0-5V at least, more likely 10VPP, so one would have to come up with additional circuitry anyways.
 
Lots of good discussion, but i figured I would add my current audio desires to the list.

My use is to add sound to Sci-Fi props, such as blaster pistols and light sabers. So I need the small size to fit inside the props. Sound quality is not a big deal, because the speakers are pretty much crap anyway. :) It just needs to be heard.

One useful feature would be to loop a single track.
 
I'll try to squeeze a place to add a 23LC1024 onto the bottom right corner of the board.

I saw the Open Music Labs claim "you can even use it as a high quality ADC and DAC for signals of all kinds". They also promote their shield as capable of 24 bits. While those statement aren't necessarily false, I believe it's safe to say they do not really genuinely the product's capability. I suppose every organization or company needs to decide what they consider acceptable for marketing their products. Those claims are pretty far beyond what I'd publish.
 
This is a good idea !
My wishes :

AKM or cirrus logic converters are used in pro audio cards.

CD quality is minimal (stereo outs 44.1Khz 16 bits), and is enough for me.

I want to create a synth. polyphonic wavetable synth if possible. with low latency. You press a midi key of the piano. you hear the sound with near 0 latency.
Maybe I can dream of DSP like reverb ...

One Line Out stereo jack is good. so you can plug any speakers. with built in jack, or 3 holes.

For me, Audio Input is not needed, because you need a mic preamp, and good quality mic preamp is another story.

Built in amp is not needed.

I don't need volume knob. Just let the volume at max by default, and we can lower it by software.

Regards,

Dan
 
Integrating USB audio is something I'd like to do at some point, but definitely not until there's at least a first alpha release with basic functionality.

Acknowledged.

Still, it would be nice in the future to build a DIY teensy-based usb audio card with multiple inputs (if it's ever possible considering the needed processing power/throughput, I am not knowledgeable enough to assess this), with open source drivers that would work on any platform...

Best wishes for this audio project!
 
So when this SRAM IC will be used as a buffer, will the accompanying audio library depend on that chip (in other words: will everyone who wants to use the audio library have to attach this IC to the T3) ? I wouldn't consider this a bad thing, just curious.
If there's a rotary encoder which fits into that small space, I could probably do this. The only rotary encoders I have are much larger.
Do you have any specific parts in mind? A link to the datasheet with mechanical drawing or recommended PCB footprint would be helpful.
I tried to find a small rotary encoder, but I really could not find anything sufficiently small to fit in the space a small pot would occupy. :(
 
Still, it would be nice in the future to build a DIY teensy-based usb audio card with multiple inputs (if it's ever possible considering the needed processing power/throughput, I am not knowledgeable enough to assess this), with open source drivers that would work on any platform...

Teensy3 is certainly capable of moving pretty substantial amounts of data around. Moving 44 kHz 16 bit stereo uses in a few percent of the CPU time.

Today, the USB code doesn't really support isync transfers. The code is all there if you want to try hacking, but the USB stuff is quite complex. I'll work on it eventually, but many other things are much higher priority.
 
So when this SRAM IC will be used as a buffer, will the accompanying audio library depend on that chip

Only certain objects (if any) would depend on that chip.

(in other words: will everyone who wants to use the audio library have to attach this IC to the T3) ? I wouldn't consider this a bad thing, just curious.

All the other stuff will work without that specific chip.

In fact, whether anything ever gets written for that chip still remains to be seen. But if it does, it'll only be specific objects than need a deep buffer. Most likely it would be a delay object, or perhaps reverb simulating a very large room.
 
it would be nice in the future to build a DIY teensy-based usb audio card

Teensy3 is certainly capable of moving pretty substantial amounts of data around. Moving 44 kHz 16 bit stereo uses in a few percent of the CPU time.

Today, the USB code doesn't really support isync transfers. The code is all there if you want to try hacking, but the USB stuff is quite complex.

I'm already working on that; in fact, I'm finishing a design based on the WM8740 and the WM8786, with a pair of PGA4311 for volume control, and an input selector with ADG333As analog switches, that activates an LME49724 which converts the unbalanced signal of a guitar to a balanced one, to correctly drive the ADC; there's also a DC-DC converter that converts the USB 5 V to +/- 5 V to correctly drive all of the analog subcircuits. I'm also already working on the USB library stuff, but as Paul said, that stuff is really complex; right now, I've managed to let the Teensy enumerate as a USB compliant microphone, and it also streams some data, although not as it should be; there's a topic I opened for that, if anyone needs more in-depth information.
 
I added 5 knobs and 2 buttons to my prototype. So far, I'm only controlling the main volume and the frequency of a DDS sine wave. Will do more soon.

audio_proto.jpg
 
Only certain objects (if any) would depend on that chip.



All the other stuff will work without that specific chip.

In fact, whether anything ever gets written for that chip still remains to be seen. But if it does, it'll only be specific objects than need a deep buffer. Most likely it would be a delay object, or perhaps reverb simulating a very large room.

oh sure, that wouldn't make a great deal of sense, ie making anything dependent on an (as yet) untested chip. btw, i'd be curious to know if anyone knows of any alternatives (low pin count ones, i mean). i only brought it up as RAM seemed to be one critical resource/thing that was missing in my messing around with teensy 3 audio so far; not audio quality or processing speed. (i've made my own wm8731 board a while back as i need a lot of buffering circuitry -5/5V -> 0-3V and v.v.) for example, i have no problems running 4 linearly interpolated lookuptable oscillators plus some other not particularly optimized stuff in the DMA callback, but already going down to low frequencies with a basic karplus strong sketch i've tried proved a bit tricky, and that's monophonic. delay more generally is an obvious example, but so is most audio processing that is to take place between input and output, or on whatever is stored on your SD card .. other than bitcrushing.
 
Last edited:
Status
Not open for further replies.
Back
Top