Hi,
I got a Feather M0 Express ⁽¹⁾ and the Prop-Maker FeatherWing. Although I made an initial prototype of my project in CircuitPython, I am concerned about the resource use, and so am rewriting it in C++. All is well except for the audio—the official guide basically abandons us, and says to use CircuitPython instead ⁽²⁾.
I'm not particularly scared of writing my own audio library, but I'd still rather not if possible. If I do have to, I'm not clear on exactly how it should work. At a total guess, one sets pin A0 (a 10-bit true analog output) in an interrupt service routine, which also handles loading and buffering audio file(s) loaded from SPI flash?
⁽¹⁾ I wanted the M4, but it has been out of stock for a while :V
⁽²⁾ Which seems like something of an oversight; maybe that should be improved.
Feather M0 Express + Prop-Maker FeatherWing + Arduino (not CircuitPython) Audio
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- geo2
- Posts: 5
- Joined: Sat Sep 14, 2013 5:13 pm
- dastels
- Posts: 14278
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Feather M0 Express + Prop-Maker FeatherWing + Arduino (not CircuitPython) Audio
This might be a good place to start exploring: https://learn.adafruit.com/synthesizer-design-tool.
Dave
Dave
- geo2
- Posts: 5
- Joined: Sat Sep 14, 2013 5:13 pm
Re: Feather M0 Express + Prop-Maker FeatherWing + Arduino (not CircuitPython) Audio
Hmmm; that essentially suggests using https://github.com/adafruit/Audio, a fork of Teensy Audio Library, an audio library for the Teensy line of microcontrollers. However, the tutorial uses it with with an M4 board, which, with similar pins, sounds encouragingly close.
So, I tried out the Adafruit fork. It doesn't compile for the M0 Express; the file included by "Arduino/libraries/Audio_-_Adafruit_Fork/AudioStream.h", line 71, doesn't exist. Commenting it out produces a lot of other errors (after a lengthy compile time, of course). The Adafruit fork hasn't been touched in three years, so it's not terribly surprising it has bit-rotted. The original library looks more up-to-date, but it's not clear if it supports the M0, and doesn't seem to like being installed from the Arduino IDE library manager.
So, I tried out the Adafruit fork. It doesn't compile for the M0 Express; the file included by "Arduino/libraries/Audio_-_Adafruit_Fork/AudioStream.h", line 71, doesn't exist. Commenting it out produces a lot of other errors (after a lengthy compile time, of course). The Adafruit fork hasn't been touched in three years, so it's not terribly surprising it has bit-rotted. The original library looks more up-to-date, but it's not clear if it supports the M0, and doesn't seem to like being installed from the Arduino IDE library manager.
- dastels
- Posts: 14278
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Feather M0 Express + Prop-Maker FeatherWing + Arduino (not CircuitPython) Audio
Ah. OK, yeah, it's a SAMD51 (aka M4) port. You might be out of luck, which really surprises me. The SAMD21 is a bit underpowered for some things. Though I wouldn't think basic playing audio files would be a challenge for it.
There are two "upgrade" paths for you: switch to a Feather M4 with the propmake wing or a propmater Feather https://learn.adafruit.com/adafruit-rp2 ... er-feather.
Dave
There are two "upgrade" paths for you: switch to a Feather M4 with the propmake wing or a propmater Feather https://learn.adafruit.com/adafruit-rp2 ... er-feather.
Dave
- geo2
- Posts: 5
- Joined: Sat Sep 14, 2013 5:13 pm
Re: Feather M0 Express + Prop-Maker FeatherWing + Arduino (not CircuitPython) Audio
Well, as mentioned, the Feather M4 Express is out-of-stock. The Prop-Maker Feather would have been ideal, but it's also apparently out-of-stock.
In any case, the Feather M0 Express specifically has pin A0 for audio out, and the Feather M0 Express + Prop-Maker FeatherWing combination is something you guys explicitly recommend and support. So, I'm fairly confident it's possible. The issue is just that that code that does that is all in CircuitPython; I need Arduino code for this because of the project constraints. Regardless of the hardware, that's not something I have.
In any case, the Feather M0 Express specifically has pin A0 for audio out, and the Feather M0 Express + Prop-Maker FeatherWing combination is something you guys explicitly recommend and support. So, I'm fairly confident it's possible. The issue is just that that code that does that is all in CircuitPython; I need Arduino code for this because of the project constraints. Regardless of the hardware, that's not something I have.
- adafruit2
- Posts: 21725
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Feather M0 Express + Prop-Maker FeatherWing + Arduino (not CircuitPython) Audio
the prop maker RP2040 will be in stock soon (no ETA but its not chip shortage constrained like the M4 SAMD51) and we have an example of audio playback via I2S using the second core to push audio through
https://learn.adafruit.com/adafruit-rp2 ... -example-2
https://learn.adafruit.com/adafruit-rp2 ... -example-2
- geo2
- Posts: 5
- Joined: Sat Sep 14, 2013 5:13 pm
Re: Feather M0 Express + Prop-Maker FeatherWing + Arduino (not CircuitPython) Audio
That definitely seems like the way to go for an M4. This won't work for the M0, since that is single-core, but it is interesting nonetheless. I do notice that audio seems to be written using I2S, which I'm confused by; I thought the point of the Prop-Maker was to use A0, since that is true analog, not PWM. Maybe some difference between the Feather and the FeatherWing versions.
I've been working on the approach I mentioned earlier, of setting pin A0 in an interrupt service routine. Highly relevant is the AudioZero library which, unlike all other other code that takes this approach, is very simple. Basically, this uses the TC5 hardware "timer control", which ticks at divisions of the clock rate, to fire an interrupt that writes the next sample at the right time. The timing code itself is better explained in this very nice gist. I've made various improvements to this—e.g. it seems to be better to use the TC4 timer, because that allows the timer to alternately be configured in 32-bit mode (by using TC4 and TC5 together), and there are some gotchas and refactoring to be dealt with.
Despite this progress, I still haven't gotten any sound yet, but I hope to soon.
- adafruit2
- Posts: 21725
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Feather M0 Express + Prop-Maker FeatherWing + Arduino (not CircuitPython) Audio
digital I2S audio support is baked into circuitpython whereas Arduino has to use a separate library if it works at all - audio is just not a 'first class' interface for Arduino!
i2s will get you higher audio quality, no hiss, so we really really recommend just getting a RP2040 Prop Feather - its all in one and well supported. only thing it isnt great for is MP3 playback (RP2040 isnt powerful enough) but WAV's its fine
i2s will get you higher audio quality, no hiss, so we really really recommend just getting a RP2040 Prop Feather - its all in one and well supported. only thing it isnt great for is MP3 playback (RP2040 isnt powerful enough) but WAV's its fine
Please be positive and constructive with your questions and comments.