Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 13 of 13

Thread: audio board with anything *other* than teensy 3.x?

  1. #1
    Junior Member
    Join Date
    Nov 2017
    Posts
    16

    audio board with anything *other* than teensy 3.x?

    So, long story short: I have various projects for which I sometimes want the ability to Emit Sound. And the audio board looks really cool, but I can't tell whether it's even possible to use it with anything other than teensy 3.x. I don't (I think?) care about losing access to the Cortex's DSP hardware, I am really just looking for "can play back a few samples from some hardware" functionality. I've found a lot of things that have various forms of this functionality, but most of them appear to be more expensive, or have painfully slow response times, or not be able to do more than one voice at a time, and so on. And the specs for this look like it would do what I care about, but I am not sure whether it's merely "we don't have code showing driving this from anything else" or "this really does need to be plugged into an ARM Cortex chip to even run".

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,769
    Looking at the audio shield schematics should show you that almost every embedded processor which has integrated hardware I2S and I2C units can theoretically work with the audio shield, but you’d most probably be forced to rewrite all the low level code needed to drive these interfaces.

  3. #3
    Junior Member
    Join Date
    Nov 2017
    Posts
    16
    Quote Originally Posted by Theremingenieur View Post
    Looking at the audio shield schematics should show you that almost every embedded processor which has integrated hardware I2S and I2C units can theoretically work with the audio shield, but you’d most probably be forced to rewrite all the low level code needed to drive these interfaces.
    I was thinking it looked like it should be possible to just send it instructions. I don't need anything particularly fancy, and a little bit of driving something over i2c is not usually a barrier (I think I wrote three of those this weekend). I just couldn't find anything that actually indicated either way, and the reference to the Cortex's DSP made me think that possibly it was actually relying on that for functionality in some way.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    Pretty much all the stuff the audio shield can do (for example, in this 45 minute video) is because of Teensy 3.x and the Teensy Audio Library.

    The audio shield pretty much just gives you a stereo ADC and stereo DAC. It does have an impressive list of features for adjusting those, like programmable analog signal levels. But all the features like playing 2 files, software panning, mixing, oscillators, effects, etc all come from the Teensy Audio Library.

    If you connect to something else, the actual capabilities will depend on what software exists on that other board. It's easy to take software for granted. It's easy to think only of the DSP extensions without understanding the tremendous amount of work that goes into effectively using such hardware. I can tell you it's taken years of work to build the audio lib. Doing things well, especially to allow doing many operations and processing many sounds at the same time, while also being compatible with most other Arduino libs, it no small task!

    Years ago there was a "codec shield" for ordinary Arduino boards. As far as I know, nobody ever got playing of WAV files from a SD card working, but they did manage to generate some waveforms and create some simple effects... after quite a lot of work!

    If you do try to connect to something else, two important details to consider are MCLK and I2S master vs slave mode. The SGTL5000 chip requires MCLK. It won't even come out of reset mode and allow config by SDA & SCL until you give it a clock on MCLK. Some microcontrollers have only BCLK and LRCLK on their I2S ports, but not MCLK, so if you try to use with one of those you'll need to do *something* to get MCLK. The audio lib uses I2S master mode (Teensy generates BCLK & LRCLK), so it always configures the SGTL5000 chip in slave mode. Some microcontrollers with I2S don't really support master mode.

  5. #5
    Junior Member
    Join Date
    Nov 2017
    Posts
    16
    Okay, that is indeed more than I can practically do. I'm trying to find a thing that would let me play back a small number of sounds, small enough sounds and small enough numbers of the that "just use the flash on an atmel chip" would be plenty of storage, and all the things I find for arduino have features I don't need, like "reads files from a FAT32 filesystem" and downsides I can't handle, like ">100ms before playback starts". So, yeah. This is a really cool thing, but unless I want to rework a bunch of other things in terms of teensy 3.x hardware (and run two of them, because I need two audio outs in different places and have nothing but i2c between them), it's probably not gonna solve this particular problem.

    Thanks for the detailed response!

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    Quote Originally Posted by seebs View Post
    I'm trying to find a thing that would let me play back a small number of sounds, small enough sounds and small enough numbers of the that "just use the flash on an atmel chip" would be plenty of storage,
    Teensy 3.x does this very well, except the "atmel" part.

    but unless I want to rework a bunch of other things in terms of teensy 3.x hardware
    Teensy has very good compatibility with most Arduino code & libraries. And you get so much more, like good audio.

    Maybe you should give it a try?

  7. #7
    Junior Member
    Join Date
    Nov 2017
    Posts
    16
    The specific thing I care about is QMK keyboard firmware. (If you're wondering why audio hardware: Because why shouldn't a fancy mechanical keyboard sound like a clunky old typewriter, complete with the bing whzzzz sound for return?)

    The support there for teensy 3.x isn't super stable yet, I think, although apparently it's at least potentially usable via ChibiOS. (Well, up through Teensy 3.2; 3.5 and 3.6 apparently not.) But it'd be well into the range of "this is a complete redesign", I think. Might still be worth it, though.

  8. #8
    Senior Member pictographer's Avatar
    Join Date
    May 2013
    Location
    San Jose, CA
    Posts
    630
    Not sure why you wouldn't add a Teensy 3.2 paired with the Audio Adaptor and keep running QMK on whatever supports it. $19.80 seems small compared to the number of hours of development time it would save you.

    And regarding having audio out in two places, I probably don't understand what you're doing, but couldn't you have the electronics in one place with wires going to two speakers or jacks where you need them?

  9. #9
    Junior Member
    Join Date
    Nov 2017
    Posts
    16
    Huh. That's... actually probably true, it's still not very expensive compared to the workload. I'm not sure about power consumption, but it's plausible that a teensy 3.2+audio board would use less power than I'd use doing the same thing on a 5V chip. (And the 3.2 claims to be 5V-tolerant for i2c, so I could in theory just have it listen on that bus.)

    So the deal is, I'm trying to make a mod for an existing keyboard (Ergodox EZ). Which has an atmel 32u4 in it. Or possibly build a variant board. The board's design has a single wire between two keyboard halves which is just +5V/GND/SCL/SDA for the I2C bus. I don't want to change that if I don't absolutely have to. And I want a speaker on each side. So I was looking longingly at tiny little I2S breakout boards and such, but of course, the atmel chips can't drive those. And an ARM teensy can, but at that point, I might as well spend $5 more or something to get a fancy cool audio board.

    And for now this is mostly "alter existing keyboard", but it could later become "build custom keyboard starting from this design". If I have to have the teensy 3.2 in there anyway, it'd probably be more efficient to replace the teensy 2.x (or 32u4) with it. But at that point I have to buy or make PCBs, or do a lot of hand-wiring, so it becomes sort of a pain. But hey, it's a hobby.

  10. #10
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,787
    Interesting this has come full circle since the Ergodox started as a keyboard you put a Teensy2 in, but now are fully integrated (and means you can't just swap in a Teensy3)

    What sort of audio fidelity are you after? The classic solution for resource limited audio is to drive an output as class D
    https://en.wikipedia.org/wiki/Class-D_amplifier
    into a carefully tuned filter and speaker, something like
    http://madscientisthut.com/wordpress...s-d-amplifier/
    So you would have a pair of low horsepower CPUs on the i2C bus whose sole function is life is to twiddle a single output pin (or a pair as a low power H bridge) from EEPROM to achieve the audio. If this was to be a commercial product shipping thousands of units at lowest cost that would be the way to go, but unless you think it would be an interesting challenge for a single keyboard there would be less labour intensive ways.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    Quote Originally Posted by seebs View Post
    The board's design has a single wire between two keyboard halves which is just +5V/GND/SCL/SDA for the I2C bus. I don't want to change that if I don't absolutely have to. And I want a speaker on each side. So I was looking longingly at tiny little I2S breakout boards and such
    Maybe you're confusing I2C with I2S?

    It's a common misunderstanding. The names look so similar. Many chips that use I2S for audio streaming also happen have I2C ports for configuration (because I2S doesn't have any provision for such things), so it's easy to get them mixed up.

    I2C and I2S are nothing alike.

  12. #12
    Junior Member
    Join Date
    Nov 2017
    Posts
    16
    I think I was initially sort of confusing them, then realized I2S was a completely different thing I didn't have. And then I confused them again when I wrote that post; I did mean I2C breakout boards, like Adafruit has a $6 board that's a 12-bit DAC.

    Lowish-fidelity is probably fine, only need mono, but I'd like good enough sample rates that things sound decent... which will need to experiment with. In practice, teensy3.2+audio board is probably actually less hassle, although I'm not sure how much power I'm looking at for two of those plus speakers.

    (I've already finished one successful mod, I have a TRRS cable for connecting the halves which has a 20x4 LCD character display.)
    Last edited by seebs; 11-27-2017 at 04:41 PM.

  13. #13
    There is a small note about the clock. The nature of the I2C is that data on the SDA line is only recorded on the up side of the CLK leg. So the clock may not need to be exactly 1MHz or 3.4Mhz

Posting Permissions

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