Comments (15)
Thanks for reporting!
Looks like I actually forgot to even test compilation, for the DAC output. Compilation should now be fixed.
However, as the README states, this mode was never actually tested in reality. By now I do have some PT8211's on my desk, but I'll still have to find the time to play with them. So let me ask a few follow-up questions:
-
Can you elaborate on "sound is a bit distorted" (or even scope the output, if you have the means)? What exactly do you hear?
-
Did you make sure to scale the audio correctly? On the ESP you will want the output scaled to 16 bits in updateAudio().
-
When trying one of the other output modes on the ESP (PDM_VIA_SERIAL or PDM_VIA_I2S) do you get the same distortions, or are they specific to the external dac method? The other output modes are tested, and while their resolution is limited, they are known to work without distortion.
-
I do not think this is the issue, but could you try whether the distortion goes away with the line changed to:
i2s_write_lr(updateAudio(), 0);
Thanks!
from mozzi.
Some examples to clarify my question 1: Is the distortion permanent or intermittent, pulsed, etc.? Is the chopping, ticking, etc.? Does it affect only loud sounds, or all sounds? Can it be described as high/low frequency noise added to the output, or is the output signal itself malformed?
from mozzi.
Hi. I'll try to explain better and all test I've done.
1 - I think output is very loud. i2s_write_lr(updateAudio(), 0);
did a good job but out now is so soft...I need to increase gain in my soundcard and electrical noises appear when I move the mouse. External power plug is really better than powering from PC USB but output is not clear at all. Arduino nano+MCP DAC is clear on both power situations. May be my ESP8266 quality is not very good.
Also tried AUDIO_RATE to 32768, same result.
I don't know how to scope output.
2 - In fmsynth example I add <<4 to the return line:
return (int)aCarrier.phMod(modulation)<<4;
Now sound is clear :) but...in that example, when pitch notes are high, sound is distorted. The single issue is that everything has a higher pitch compared to atmega328+mcpdac. it's not important for me.
3 - I did not tried it. I only tested PDM_VIA_I2S when I was building a drum machine [https://zircothc.wordpress.com/] and, of course I prefer I2S DAC output.
4 - This trick and <<4 did the job :)
I'm very happy now ;)
Thank you very much.
from mozzi.
Thanks for the reply. So as far as I understand, the remaining issue now is that the pitch appears to be too high? Could you perhaps try whether changing line 565 in MozziGuts.cpp from
i2s_set_rate(AUDIO_RATE*PDM_RESOLUTION);
to i2s_set_rate(AUDIO_RATE);
makes any difference?
from mozzi.
Hi.
I think line is 580 (on mozzi downloadable master version). Anyway pitch is still high and...yes, this is the only issue now.
;)
from mozzi.
Sorry, I forgot to mention that I've also tried #define AUDIO_RATE 32768
High pitchs now are cleaner than audio rate 16384, not distorted, but still same pitch higher.
Everything is tested with fmsynth example ;)
from mozzi.
Yes, I meant line 580. This is very likely still the source of the problem, but I have no idea, why it would be wrong. You could try AUDIO_RATE/2 or similar values, here, to see what happens. But I guess I may just have to finally solder in one of those PT8211s and try for myself...
PS: Pretty cool project you have there!
from mozzi.
Hi.
Combination of AUDIO RATE 32768 plus AUDIO_RATE/2 gives a good sound, the pitch is like atmega+mcpdac sound (yeah!) but now, note changes on fmsynth example are slow-slow ;)
Excuse me if I need to open a new Issue for this offtopic:
External DAC feature is amazing. I used to hack mozzi with a trick I saw in mozzi google forum years ago to use external DAC instead of PWM output, but yours is better, love quality output. But everytime I change between esp8266 and AVR I need to comment #define EXTERNAL_DAC
to avoid compile errors (MCP49xx library uses PORT access)
I tried:
#if IS_AVR() #define EXTERNAL_DAC #endif
but it doesn't compile (error: missing binary operator before token "(")
Thank you very much.
from mozzi.
Hm, ok. I was working with the theory that all processing was simply sped up, and in fact my suggestion would have been expected to slow down both the frequency, and the note changes, alike.
But you're saying it's really just the frequency that is off. Very strange. Are you sure that Atmega+MCP-dac is playing at the correct frequency, or could it be that this is the one that needs fixing? E.g. could you cross-test with one of the "classical" output modes on AVR?
Regarding the compiler-error you get, that probably means that IS_AVR()
has not yet been defined at that point in the sources. It should be safe to simply add include <hardware_defines.h>
above your #if IS_AVR()
.
from mozzi.
from mozzi.
Sorry, I was busy.
Well, pitch is not really an issue. May be you can close this issue.
Actually I'm triying to port 4 mozzi synths/sequencers I made (arduino nano+mpcdac) based on knob_LightLevel_FMsynth and AMsynth examples that I used to play audio textures on live show. May be ESP8266 is not the board I have to use: only one ADC and my "things" need 8 pots each. But.. a DUE board...would be nice.
Offtopic again, sorry:
I'm not an expert but I added Arduino DUE to mozzi library. It was so easy after you wrote include <hardware_defines.h>
. Then I saw how to do that: only need to edit 3 files and some #if IS_DUE()
did the job.
I used DueTimer.h
To do: May be add stereo is easy (DUE has DAC0 and DAC1)
Wow, I'm very happy. DUE has lots of inputs vs ESP8266.
Thank you again :)
from mozzi.
Would you like to add DUE compatibility for other Mozzi users too, with credit to you? Maybe you could make a pull request for your code? Or attach the changed files here, or in a new issue?
from mozzi.
Hi. Sorry, I don't know how exactly github works, so, I better attach files I modified from current downloadable version.
At first I modified only 3 files (hardware_defines.h, MozziGuts.cpp and MozziGuts.h) but added a new AudioConfigDUE.h and also modified mozzi_analog.cpp to be able to use mozziAnalogRead() as analogRead() without issues.
Tested with some of the library examples: Knob_LightLevel_x2_FMynth, FMsynth, PWM_Phasing, etc.
Only needed to add <<3 or <<4 on return value to get a good volume on UpdateAudio()
DueTimer library (https://github.com/ivanseidel/DueTimer) is needed.
from mozzi.
Hi !
I'm testing the ESP8266's port of mozzi without external DAC on a Wemos d1 Lite.
I had similar problems about output sound being permanently very distorded (both with PDM_VIA_I2S
and PDM_VIA_SERIAL
) and not at all at the right frequencies.
I managed to solve the issue by adding <<8
to the return value of UpdateAudio(), for instance in the Sinewave.ino example.
It now outputs the right frequency and also set higher amplitude to the output signal, which it also nice. Here below an image of the FFTs
This is what you mean by
Did you make sure to scale the audio correctly? On the ESP you will want the output scaled to 16 bits in updateAudio().
???
Another question, it seems to me that the values for PDM_VIA_I2S
and PDM_VIA_SERIAL
are switch here. Would that be possible ?
Anyway it sounds quite nice now, great work !
Thanks !!!
from mozzi.
Thanks for that insight. Yes, by "scale the audio correctly", I meant the left-shift, indeed. It's still interesting to see tonal noise in the unscaled (and thus very silent) signal. In theory I would still expect a clear peak at the signal frequency. Do the audible frequencies change when changing the oscillator frequency, or are those "static" noise?
Regarding the switched values, I don't know what you mean. This just defines PDM_VIA_SERIAL, and PDM_VIA_I2S as two different arbitrary numbers, so that as a user you can set e.g.
#define ESP_AUDIO_OUT_MODE PDM_VIA_SERIAL
and the lib can have code like e.g.:
#if (ESP_AUDIO_OUT_MODE == PDM_VIA_SERIAL)
//...
#endif
from mozzi.
Related Issues (20)
- 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
- Compilation errors when including both WaveFolder.h and ResonantFilter.h HOT 3
- Unable to compile for Atmega328PB with Arduino IDE HOT 3
- Sample example not working on UNO R4 HOT 11
- Arduino Nano 33 IoT tested and works with the output on DAC0, which is also called A0 HOT 2
- Output frequency 0.25% off on AVRs HOT 1
- RFC: Mozzi 2.0 part 1: Single compilation unit HOT 7
- RFC: Mozzi 2.0 part 2 - Configuration restructuring HOT 7
- Improving fixMath HOT 5
- Please Change Mozzi's License HOT 10
- Using Mozzi and I2C library for LCD HOT 14
- RFC: Mozzi 2.0 part 3 - Miscellanious
- UNO R4 port broken HOT 2
- Compatability/Compilation Issues w/ Nano 33 BLE Sense HOT 5
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.