From f837cf1e9f67a9153dfa70baf2cd9db083ef572e Mon Sep 17 00:00:00 2001 From: Thomas Friedrichsmeier Date: Mon, 13 Nov 2023 20:17:56 +0100 Subject: [PATCH] Start obsoleted files start adding porting table --- AudioConfigHiSpeed14bitPwm.h | 37 ------------ AudioConfigStandard9bitPwm.h | 25 -------- AudioConfigStandardPlus.h | 26 --------- Readme_Mozzi_2_0.md | 26 +++++++++ mozzi_config.h | 107 ----------------------------------- 5 files changed, 26 insertions(+), 195 deletions(-) delete mode 100644 AudioConfigHiSpeed14bitPwm.h delete mode 100644 AudioConfigStandard9bitPwm.h delete mode 100644 AudioConfigStandardPlus.h create mode 100644 Readme_Mozzi_2_0.md delete mode 100644 mozzi_config.h diff --git a/AudioConfigHiSpeed14bitPwm.h b/AudioConfigHiSpeed14bitPwm.h deleted file mode 100644 index 6123257b4..000000000 --- a/AudioConfigHiSpeed14bitPwm.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef AUDIOCONFIGHISPEED14BITPWM_H -#define AUDIOCONFIGHISPEED14BITPWM_H - -/* -14 bit sound at 16384 Hz and 125kHz pwm rate -Timer 1: PWM 125kHz -Timer 2: called at AUDIO_RATE 16384 Hz, setting Timer1 pwm levels -Output on Timer1, low uint8_t on Pin 10, and high uint8_t on Pin 9 (on 328 based Arduino boards) -Add signals through a 3.9k resistor on high uint8_t pin and 499k resistor on low uint8_t pin. -Use 0.5% resistors or select the most accurate from a batch. -As discussed on http://www.openmusiclabs.com/learning/digital/pwm-dac/dual-pwm-circuits/ -Also, there are higher quality output circuits are on the site. - -Boards, pins and resistor positions are documented in MozziGuts.h -*/ - -/* PWM carrier frequency, for HIFI this should be well out of hearing range, about 5 times the nyquist frequency if possible. */ -#define PWM_RATE 125000 -// following doesn't play nice -//#define PWM_RATE 65536 // count will be 244 (7+ bits) on each pin = 14+ bits - - -// pins defined in TimerOne/config/known_16bit_timers.h -#define AUDIO_CHANNEL_1_highByte_PIN TIMER1_A_PIN // 3.9k resistor -#define AUDIO_CHANNEL_1_lowByte_PIN TIMER1_B_PIN // 499k resistor -#define AUDIO_CHANNEL_1_highByte_REGISTER OCR1AL -#define AUDIO_CHANNEL_1_lowByte_REGISTER OCR1BL - -#define AUDIO_BITS_PER_REGISTER 7 -#define AUDIO_BITS 14 - -/* Used internally to put the 0-biased generated audio into the right range for PWM output.*/ -// 14 bit -#define AUDIO_BIAS ((uint16_t) 1<<(AUDIO_BITS-1)) - - -#endif // #ifndef AUDIOCONFIGHISPEED14BITPWM_H diff --git a/AudioConfigStandard9bitPwm.h b/AudioConfigStandard9bitPwm.h deleted file mode 100644 index e7c9402c2..000000000 --- a/AudioConfigStandard9bitPwm.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef AUDIOCONFIGSTANDARD9BITPWM_H -#define AUDIOCONFIGSTANDARD9BITPWM_H - - -/** @ingroup core -This is the dynamic range of Mozzi's audio output in STANDARD mode. -It is equal to Timer1.pwmPeriod calculated for interrupt rate 16384. -It's included in the documentation because it's a slightly unusual number and useful to know -about when you're writing sketches. -*/ -#define STANDARD_PWM_RESOLUTION 488 - -/* PWM carrier frequency, for standard mode this will be the same as the audio rate. */ -#define PWM_RATE 16384 - -/* Used internally to put the 0-biased generated audio into the right range for PWM output.*/ -#define AUDIO_BIAS ((uint8_t) 244) - -// Used internally. If there was a channel 2, it would be OCR1B. -#define AUDIO_CHANNEL_1_OUTPUT_REGISTER OCR1A - -#define AUDIO_CHANNEL_1_PIN TIMER1_A_PIN // defined in TimerOne/config/known_16bit_timers.h - -#endif // #ifndef AUDIOCONFIGSTANDARD9BITPWM_H - diff --git a/AudioConfigStandardPlus.h b/AudioConfigStandardPlus.h deleted file mode 100644 index 0d0b3c27a..000000000 --- a/AudioConfigStandardPlus.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef AUDIOCONFIGSTANDARDPLUS_H -#define AUDIOCONFIGSTANDARDPLUS_H - - -/** @ingroup core -This is the dynamic range of Mozzi's audio output in STANDARD mode. -It is equal to Timer1.pwmPeriod calculated for interrupt rate 16384. -It's included in the documentation because it's a slightly unusual number and useful to know -about when you're writing sketches. -*/ -#define STANDARD_PWM_RESOLUTION 488 - -/* Used internally for standard mode because the audio gets updated every alternate ISR, so the PWM rate is double the audio update rate */ -#define PWM_RATE 32768 - -/* Used internally to put the 0-biased generated audio into the right range for PWM output.*/ -#define AUDIO_BIAS ((uint8_t) 244) - -// Used internally. If there was a channel 2, it would be OCR1B. -#define AUDIO_CHANNEL_1_OUTPUT_REGISTER OCR1A -#define AUDIO_CHANNEL_2_OUTPUT_REGISTER OCR1B - -#define AUDIO_CHANNEL_1_PIN TIMER1_A_PIN // defined in TimerOne/config/known_16bit_timers.h -#define AUDIO_CHANNEL_2_PIN TIMER1_B_PIN - -#endif // #ifndef AUDIOCONFIGSTANDARDPLUS_H diff --git a/Readme_Mozzi_2_0.md b/Readme_Mozzi_2_0.md new file mode 100644 index 000000000..e052b66c7 --- /dev/null +++ b/Readme_Mozzi_2_0.md @@ -0,0 +1,26 @@ +Porting to Mozzi 2.0 + +// TODO: properly type up + + +changed config names and semantics TODO (incomplete) + +audio modes mapping + + - STANDARD: MOZZI_OUTPUT_PWM with PWM_RATE == AUDIO_RATE + - STANDARD_PLUS: MOZZI_OUTPUT_PWM with PWM_RATE == 32768 + - HIFI: MOZZI_OUTPUT_2PIN_PWM + - EXTERNAL_AUDIO_OUTPUT (without BYPASS_MOZZI_BUFFER): MOZZI_OUTPUT_EXTERNAL_TIMED + - EXTERNAL_AUDIO_OUTPUT (with BYPASS_MOZZI_BUFFER): MOZZI_OUTPUT_EXTERNAL_CUSTOM + +further + - USE_AUDIO_INPUT: MOZZI_AUDIO_INPUT + +simple renames: + - AUDIO_RATE: MOZZI_AUDIO_RATE + - CONTROL_RATE: MOZZI_CONTROL_RATE + +all new + - MOZZI_ANALOG_READS + - MOZZI_COMPATIBILITY_LEVEL + diff --git a/mozzi_config.h b/mozzi_config.h deleted file mode 100644 index 1f9d4dba1..000000000 --- a/mozzi_config.h +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef MOZZI_CONFIG_H -#define MOZZI_CONFIG_H -#include "hardware_defines.h" - -/* -Edit this file if you want to choose your own configuration options. -*/ - - -/** @ingroup core -AUDIO_MODE holds the audio mode setting. -Select STANDARD (deprecated), STANDARD_PLUS or HIFI audio output mode in the Mozzi/mozzi_config.h file with -\#define AUDIO_MODE STANDARD_PLUS or \#define AUDIO_MODE HIFI. -In Mozzi/config.h, comment one of these options in and the others out to set the audio mode. - -In STANDARD_PLUS mode the sample resolution is 488, -which provides some headroom above the 8 bit table resolution currently used by -the oscillators. You can look at utility/TimerOne library for more info about how -interrupt rate and pwm resolution relate. - -HIFI audio mode enables much higher quality output by combining signals from pins 9 and 10. -For HIFI mode, edit Mozzi/mozzi_config.h to contain \#define AUDIO_MODE HIFI, -and comment out \#define AUDIO_MODE STANDARD and \#define AUDIO_MODE STANDARD_PLUS. - -@note Teensy 3.* plays 12 bit audio in STANDARD or STANDARD_PLUS modes, and has no HIFI mode. -*/ -//#define AUDIO_MODE STANDARD -#define AUDIO_MODE STANDARD_PLUS -//#define AUDIO_MODE HIFI - - -/** @ingroup core -Holds the audio rate setting. -AUDIO_RATE can be \#defined as 16384 or 32768 Hertz in Mozzi/mozzi_config.h. - -Mozzi's original audio mode, now called STANDARD, uses 16384 Hz, chosen as a -compromise between the sample rate (interrupt rate) and sample bitdepth (pwm -width), which are interdependent due to the way pulse wave modulation is used to -generate the sound output. -An AUDIO_RATE of 32768 Hz works in STANDARD_PLUS and HIFI modes. -Of course, doubling the sample rate halves the amount of time available to calculate the each sample, so it -may only be useful for relatively simple sketches. The increased frequency response can also make -unwanted artefacts of low resolution synthesis calculations more apparent, so it's not always a bonus. - -Another factor which is important for Mozzi's operation is that with AUDIO_RATE -being a power of two, some internal calculations can be highly optimised for -speed. - -In STANDARD and STANDARD_PLUS modes, the sample resolution is 488, -which provides some headroom above the 8 bit table resolution currently used by -the oscillators. You can look at the TimerOne library for more info about how -interrupt rate and pwm resolution relate. - -HIFI audio mode enables much higher quality output by combining signals from pins 9 and 10. -For HIFI mode, edit Mozzi/mozzi_config.h to contain \#define AUDIO_MODE HIFI, -and comment out \#define AUDIO_MODE STANDARD and \#define AUDIO_MODE STANDARD_PLUS. - -@todo Possible option for output to R/2R DAC circuit, like -http://blog.makezine.com/2008/05/29/makeit-protodac-shield-fo/ . -Mozzi-users list has a thread on this. -*/ -#define AUDIO_RATE AUDIO_RATE_PLATFORM_DEFAULT -//#define AUDIO_RATE 16384 // default on AVR / classic Arduino -//#define AUDIO_RATE 32768 // default on most other platforms -//#define AUDIO_RATE 65536 // try on Teensy3/3.1 or other strong cpus - - -//#define USE_AUDIO_INPUT true - -/** @ingroup core -This sets which analog input channel to use for audio input, if you have uncommented -\#define USE_AUDIO_INPUT true -in mozz_config.h -@note You may have to call setupFastAnalogReads(FASTEST_ADC) after setupMozzi(), when using this. -*/ -#define AUDIO_INPUT_PIN 0 - - -/** @ingroup core -This sets allows to change from a single/mono audio output channel to -stereo output. To actually generate two channels, your updateAudio()-function -should return a StereoOutput(). Sketches returning a MonoOutput() in a stereo -config, or vice versa will continue to work, but will generate a warning a -compile time. - -@note This option superseeds the earlier STEREO_HACK, which is still available at - the time of this writing, but should not be used in new sketches. - -@note At the time of this writing, only MONO and STEREO are supported. The value of - MONO is 1 and the value of STEREO is 2, so future extensions are also expected - to set this to the number of available channels. */ -#define AUDIO_CHANNELS MONO -//#define AUDIO_CHANNELS STEREO - -/** @ingroup core -Defining this option as true in mozzi_config.h allows to completely customize the audio output, e.g. for connecting to external DACs. -For more detail, @see AudioOuput . -*/ -#define EXTERNAL_AUDIO_OUTPUT false -//#define EXTERNAL_AUDIO_OUTPUT true - -/** @ingroup core -Only used when EXTERNAL_AUDIO_OUTPUT is set to true: The resolution to use for audio samples, internally. You will usually set this to match the -output resolution of your DAC. 16 is the default value, here. Note that 16 bits is also the maximum currently supported on AVR. */ -//#define EXTERNAL_AUDIO_BITS 16 - -#endif // #ifndef MOZZI_CONFIG_H