Comments (15)
Thanks for the feedback. I have committed the following, then: f49e8d0
I assume that closes the issue, but please reopen, if it doesn't.
from mozzi.
Did you scale the audio to 12 bits on teensy? Otherwise it will simply come out too silent, and with a worse signal-to-noise ratio.
from mozzi.
Oh, sorry, did not read well. You are not using a teensy.
I don't think the SAMD21-support has received a lot of testing so far, and I'm not sure, what board it was originally developped, for. I still suspect an audio scaling issue, though 12 bits may not be the correct scaling to use. (The adafruit page mentions a 10bit DAC, but the code seems to assume 12 bits).
Experiment with scaling your audio output to 8, 10, and 12 bits, testing what sounds best. Also, you may have to adjust AudioConfigSAMD21.h, which assumes 12 bits (setting the center point to 2048).
from mozzi.
I am experiencing a similar issue. Running the Sinewave demo on a Feather M0 produced no sound whatsoever, until I changed AUDIO_BIAS in AudioConfigSAMD21.h from 2048 to 1024. Then, I got output that sounded like @gregsadetsky 's "degraded" sinewave.
@tfry-git: I would like to try and assist in testing fixes to this, but I don't know what you mean by scaling the audio output to different bit widths. I thought Mozzi always used 16 bits?
from mozzi.
Wow, it works!!!! Setting
#define AUDIO_BIAS ((uint16_t) 512)
works!! :-)
Thank you so, so much!
Should there be a pre-processor directive, or additional documentation about this?
from mozzi.
@gregsadetsky I am also working with a Feather M0, and I am unable to replicate your success. Even after setting AUDIO_BIAS to 512 in AudioConfigSAMD21.h, I still get a Sinewave that sounds like your degraded one.
Could you share the code that worked for you?
from mozzi.
I will take a look again, but I do remember the change being just what I posted above (the #define
line).
Just to be sure (as this was a bit confusing to me initially), did you change the value in the AudioConfigSAMD21.h
file that's within the Arduino library directory, or did you download a fresh copy of Mozzi that you included in your project directory, and made the change there?
I'm simply asking to make sure that you did the change in the code that was indeed compiled. Out of curiosity, if you delete the Mozzi directory where you did the change, does that create a compilation error?
Also, I remember trying much smaller values than 512 for fun and it did end up creating a "bit crushing" audio effect (a similar-ish distortion to what I posted). Could you try that (256, 128, etc.), just to make sure, again, that your changes in AudioConfigSAMD21.h
are being taken into account? Cheers
from mozzi.
I would like to try and assist in testing fixes to this, but I don't know what you mean by scaling the audio output to different bit widths. I thought Mozzi always used 16 bits?
Unfortunately, Mozzi does not always use 16 bits. For instance on the classic AVR architectures, it uses just over 8 bits, an STM32 it uses 10 bits, and on ESP8266 it uses 16 bits. You will always have to make sure that your updateAudio() returns the correct range of values for your configuration. This is not easy to fix, but see #43 for one idea (and more background).
This might also be the reason why your sinewave still sounds distorted. Make sure updateAudio() returns values between -511 and 512.
Should there be a pre-processor directive, or additional documentation about this?
Definitely. Do you think there is a compiler defintion that will identify the Feather M0, realiably? Then this could be used in AudoConfigSAMD21.h, as appropriate.
from mozzi.
Definitely. Do you think there is a compiler defintion that will identify the Feather M0, realiably? Then this could be used in AudoConfigSAMD21.h, as appropriate.
There's an ADAFRUIT_FEATHER_M0
flag/constant that - as far as I understand - comes from adafruit_samd's boards.txt: ... extra_flags=... -DADAFRUIT_FEATHER_M0
.
adafruit_samd needs to be installed (see here) in order to use the Feather M0 family of boards with the Arduino IDE.
As an example, you can see this constant used here, for a Feather M0-based board with built-in radio (this one).
from mozzi.
@tfry-git I think I've found another possible issue.
On line 518 of MozziGuts.cpp, the IS_SAMD21() case sets analogWriteResolution to 12 bits, even though the DAC on the SAMD21 is 10 bits.
According to the analogWriteResolution docs, setting the resolution to something higher than the hardware's actual resolution results in the remaining bits being dropped - only the first 10 are actually used. I don't have access to the hardware right now, but is that a possible problem?
from mozzi.
Yes, this is a possible problem. But it's really hard to fix this kind of problem, without having the hardware to test (and I don't that that, either).
from mozzi.
Hi!
Sorry for dropping the ball on this one. I have committed an experimental fix for this. Could you please do
git pull
git checkout testing/SAMD21_analog_resolution
and then test with that? If it works, I can merge this into the official branch. In theory this should now work out of the box (you'll still have to make sure updateAudio() returns values in the +/-512 range).
Thanks!
from mozzi.
I've been working with a SAMD21 and have run into this issue too. @tfry-git's solution in the branch is correct for all SAMD21 chips.
The SAMD21 only has a single 10-bit DAC on it. (Its _ADC_s are 12-bit, however). This includes the Gemma M0 that support is listed for - that only has a 10-bit DAC output.
I'd put together my own PR but it seems a relatively straightforward fix...
from mozzi.
Looks good - only other thing you might want to change is AnalogWriteResolution
in MozziGuts.cpp
, line 542. I didn't find this made any difference, but it's one thing I could think of.
from mozzi.
from mozzi.
Related Issues (20)
- Teensy LC: conflict between I2C and ADC HOT 16
- Ambiguity in `fromAlmostNBit` for 32bits platforms HOT 4
- Problem installing under Arduino ise 2.0.0-rc HOT 4
- LowPassFilter coefficients incorrectly calculated HOT 4
- Audio Input causing high Frequency feedback (over time)
- Wavefolder HOT 5
- Add note to installation instructions not to use Releases versions HOT 1
- Teensy 4.1 high definition circuitry HOT 1
- StateVariable centre frequency depends on Q HOT 3
- EXTERNAL_AUDIO_OUTPUT not working on RP2040? HOT 7
- Hardware support for the PicoADK RP2040 DSP Board HOT 7
- rPi Pico RP2040 Documentation HOT 3
- Conflict between StateVariable and ResonantFilter enum filter types HOT 3
- multiline2.h non-functional? HOT 2
- Make new release HOT 15
- triangle warm 8129 table includes values outside valid range HOT 1
- Arduino giga port HOT 4
- getAudioInput not defined HOT 2
- The randSeed() argument type is different in the header and source files. HOT 2
- Stereo - Strange error compilation depending if a function was define before updateAudio() - Problem with preprocessor ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mozzi.