Comments (4)
I don't have a teensy, myself, so my answer is guesswork to a degree. But looking at the code, mozzi uses only ADC_0, and as far as I am aware, not all analog pins are accessible by both ADC units. Likely, this is what you are running into.
Fortunately, it seems rather straight-forward to set up non-synchronous ADC on teensy (and the ADC library is already required; https://github.com/pedvide/ADC). You should be able to use ADC_1, freely.
from mozzi.
from mozzi.
Thank you both for your help!
I looked through the analog.c and mozzi_analog.h channel mappings and quite frankly didn't understand too much at first. After realizing that the code differentiates the channel mapping based on the chip the Teensy is using, for instance
#elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
for the Teensy 3.6, I tried copying this whole chunk of code into the mozzi_analog.h file, which didn't work. As suggested by tfry-git, I looked into the ADC library and found this pin scheme:
https://forum.pjrc.com/attachment.php?attachmentid=11811&d=1508341808
which shows that the "problematic" pins are in fact connected to ADC1.
So by using the ADC Library
#include <ADC.h>
Creating an object of it
ADC *adc1 = new ADC();
And using the corresponding reading function
adc1->analogRead(pin)
instead of mozziAnalogRead(pin)
the program works.
I am unsure, if this method of reading has disadvantages over the mozziAnalogRead(), since it says in the doc:
"mozziAnalogRead() reads the analog input of a chosen channel, without blocking other operations from running."
However I am calling the ADC reading in updateControl() at 64 Hz without problems so far.
So the issue is resolved and I can keep building the synth of my dreams.
Thank you very much again!
from mozzi.
adc->analogRead() waits for the conversion to complete before returning. I don't know how long that takes on teensy (by default). On the classic AVRs, it simply introduces too long delays. It might be quite ok on teensy, but if you're experiencing buffer underruns, that will be one of the first things to look into.
Alternatively, you can use non-blocking API:
adc->startSingleRead(..., ADC_1);
[...]
if (adc->isComplete(ADC_1)) {
x = adc->readSingle(ADC_1);
} else {
// keep using the previous value of x until the next iteration
}
It may be a bit cumbersome when reading multiple pins, but it should cause virtually no overhead.
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.