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)
- Optimization of `Oscil::phMod()`
- GP0 io issues on RP2040 HOT 7
- Force PWM mode for power supply on GPIO, or suggest it in documentation
- I2S dacs config in Mozzi2 HOT 9
- A question, not an issue per se: lgt8f328p HOT 2
- RP2040 is out of tune HOT 5
- URL to webpage in _About_ section is wrong HOT 2
- Port for PY32f002 - PY32F003 -PY32F030? HOT 2
- HTML styling not rendering in the Github's Readme HOT 8
- Teensy (3.6 and 4.1) CI jobs are failing HOT 3
- AudioInput does not compile with Mozzi 2.0
- ESP32 21:58:07.296 -> E (200) ADC: CONFLICT! driver_ng is not allowed to be used with the legacy driver HOT 3
- Mozzi not working on STM32 HOT 8
- MIDI port disappearing when adding Mozzi to RP2040 HOT 15
- Mozzi envelope how to produce long note HOT 5
- How do you do filter envelopes? HOT 3
- Arduino Uno R3 not enough memory HOT 2
- StereoOutput Constructor to send 2xStereo/4xMono HOT 2
- 04.Audio_Input error 'AUDIO_INPUT_PIN' was not declared in this scope HOT 8
- RP2040 PlatformIO lacks PWMAudio dependency HOT 6
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.