diff --git a/AudioOutput.h b/AudioOutput.h index 329ae15cd..f958f09fa 100644 --- a/AudioOutput.h +++ b/AudioOutput.h @@ -93,7 +93,7 @@ struct StereoOutput { StereoOutput(AudioOutputStorage_t l, AudioOutputStorage_t r) : _l(l), _r(r) {}; /** Default contstructor */ StereoOutput() : _l(0), _r(0) {}; -#if (AUDIO_CHANNELS != STEREO) +#if (MOZZI_AUDIO_CHANNELS != MOZZI_STEREO) /** Conversion to int operator: If used in a mono config, returns only the left channel (and gives a compile time warning). This _could_ be turned into an operator for implicit conversion in this case. For now we chose to apply conversion on demand, only, as most of the time using StereoOutput in a mono config, is not intended. */ diff --git a/MozziConfigExample.h b/MozziConfigExample.h index 038188985..7da4651b2 100644 --- a/MozziConfigExample.h +++ b/MozziConfigExample.h @@ -158,7 +158,7 @@ * on platforms that do support it may come with a considerable performance overhead. Don't enable, unless you need this. * * Currently allowed values are: - * - MOZZI_AUDIO_INPUT_DISABLED + * - MOZZI_AUDIO_INPUT_NONE * No audio input * - MOZZI_AUDIO_INPUT_STANDARD * Audio input enabled (currently there is only the "standard" method, but future versions might allow additional choice, here). @@ -233,7 +233,7 @@ * of the resistors and ground. This is discussed in much more detail on http://www.openmusiclabs.com/learning/digital/pwm-dac/dual-pwm-circuits/ * Also, there are higher quality output circuits are on the site. * - * On the classic Arduino Uno, the default pinout in this mode is: + * On the classic Arduino Uno, the default pinout in this mode is: * - Pin 9 (high bits) and Pin 10 (low bits) -> configurable using MOZZI_AUDIO_PIN_1 and MOZZI_AUDIO_PIN_1_LOW * * Here is table of the default pins on some other boards. Rows with an x on it have actually been tested (and importantly, the outcome recoreded; diff --git a/MozziConfigValues.h b/MozziConfigValues.h index 06958ece6..d311ad1ad 100644 --- a/MozziConfigValues.h +++ b/MozziConfigValues.h @@ -23,7 +23,7 @@ TODO: Fix documentation #define MOZZI_OUTPUT_I2S_DAC 107 #define MOZZI_OUTPUT_INTERNAL_DAC 108 -#define MOZZI_AUDIO_INPUT_DISABLED 201 +#define MOZZI_AUDIO_INPUT_NONE 201 #define MOZZI_AUDIO_INPUT_STANDARD 202 #define MOZZI_ANALOG_READ_NONE 201 diff --git a/MozziGuts.cpp b/MozziGuts.cpp index b6aad9dda..139de506a 100644 --- a/MozziGuts.cpp +++ b/MozziGuts.cpp @@ -14,7 +14,6 @@ #include "CircularBuffer.h" #include "MozziGuts.h" #include "mozzi_analog.h" -#include "mozzi_config.h" // at the top of all MozziGuts and analog files //#include "mozzi_utils.h" #include "AudioOutput.h" diff --git a/MozziGuts.h b/MozziGuts.h index 3007c2088..a178cd5d1 100644 --- a/MozziGuts.h +++ b/MozziGuts.h @@ -52,12 +52,6 @@ #include "AudioConfigRP2040.h" #elif IS_MBED() #include "AudioConfigMBED.h" -#elif IS_AVR() && (AUDIO_MODE == STANDARD) -#include "AudioConfigStandard9bitPwm.h" -#elif IS_AVR() && (AUDIO_MODE == STANDARD_PLUS) -#include "AudioConfigStandardPlus.h" -#elif IS_AVR() && (AUDIO_MODE == HIFI) -#include "AudioConfigHiSpeed14bitPwm.h" #elif IS_RENESAS() #include "AudioConfigRenesas.h" #endif diff --git a/MozziGuts_impl_AVR.hpp b/MozziGuts_impl_AVR.hpp index dd0f474dc..8e2bf0c50 100644 --- a/MozziGuts_impl_AVR.hpp +++ b/MozziGuts_impl_AVR.hpp @@ -182,11 +182,6 @@ ISR(TIMER1_OVF_vect, ISR_BLOCK) { defaultAudioOutput(); } #elif (AUDIO_MODE == STANDARD) || (AUDIO_MODE == STANDARD_PLUS) -# if (AUDIO_MODE == STANDARD_PLUS) -# include "AudioConfigStandardPlus.h" -# else -# include "AudioConfigStandard9bitPwm.h" -# endif inline void audioOutput(const AudioOutput f) { AUDIO_CHANNEL_1_OUTPUT_REGISTER = f.l()+AUDIO_BIAS; diff --git a/internal/config_check_generic.h b/internal/config_check_generic.h index 8c6f87160..2650b79b6 100644 --- a/internal/config_check_generic.h +++ b/internal/config_check_generic.h @@ -4,7 +4,8 @@ #ifndef MOZZI_CONFIG_CHECK_GENERIC_H #define MOZZI_CONFIG_CHECK_GENERIC_H -#include // in case not user-included +#include "../MozziConfigValues.h" // in case not user-included +#include "mozzi_macros.h" //// Step 1: Apply missing defaults for generic config options (not the hardware specific ones) #if not defined(MOZZI_COMPATIBILITY_LEVEL) @@ -16,7 +17,7 @@ #warning Use of STEREO_HACK is deprecated. Use AUDIO_CHANNELS STEREO, instead. #define MOZZI_AUDIO_CHANNELS MOZZI_STEREO #else -#define MOZZI_MONO +#define MOZZI_AUDIO_CHANNELS MOZZI_MONO #endif #endif @@ -30,10 +31,10 @@ //MOZZI_ANALOG_READ -> hardware specific #if not defined(MOZZI_AUDIO_INPUT) -#define MOZZI_AUDIO_INPUT_DISABLED +#define MOZZI_AUDIO_INPUT MOZZI_AUDIO_INPUT_NONE #endif -#if not defined(MOZZI_AUDIO_INPUT_PIN) +#if !MOZZI_IS(MOZZI_AUDIO_INPUT, MOZZI_AUDIO_INPUT_NONE) && !defined(MOZZI_AUDIO_INPUT_PIN) #define MOZZI_AUDIO_INPUT_PIN 0 #endif @@ -50,7 +51,7 @@ #include "config_checks_avr.h" #else // TODO - +#error oops #endif @@ -80,9 +81,6 @@ MOZZI_CHECK_POW2(MOZZI_CONTROL_RATE) // Hardware-specific checks file should have more narrow checks for most options, below, but is not required to, so let's check for anything that is wildly out of scope: MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PWM, MOZZI_OUTPUT_2PIN_PWM, MOZZI_OUTPUT_EXTERNAL_TIMED, MOZZI_OUTPUT_EXTERNAL_CUSTOM, MOZZI_OUTPUT_PDM_VIA_I2S, MOZZI_OUTPUT_PDM_VIA_SERIAL, MOZZI_OUTPUT_I2S_DAC, MOZZI_OUTPUT_INTERNAL_DAC) MOZZI_CHECK_SUPPORTED(MOZZI_ANALOG_READ, MOZZI_ANALOG_READ_NONE, MOZZI_ANALOG_READ_STANDARD) -static_assert(MOZZI_AUDIO_BITS <= (4*sizeof(AudioOutputStorage_t)), "Configured MOZZI_AUDIO_BITS is too large for the internal storage type"); - - /// Step 4: Init Read-only defines that depend on other values #if !defined(MOZZI_AUDIO_BIAS) @@ -97,7 +95,7 @@ static_assert(MOZZI_AUDIO_BITS <= (4*sizeof(AudioOutputStorage_t)), "Configured #if MOZZI_AUDIO_RATE == 8192 #define AUDIO_RATE_AS_LSHIFT 13 #define MICROS_PER_AUDIO_TICK 122 -#if MOZZI_AUDIO_RATE == 16384 +#elif MOZZI_AUDIO_RATE == 16384 #define AUDIO_RATE_AS_LSHIFT 14 #define MICROS_PER_AUDIO_TICK 61 // 1000000 / 16384 = 61.035, ...* 256 = 15625 #elif MOZZI_AUDIO_RATE == 32768 @@ -107,7 +105,7 @@ static_assert(MOZZI_AUDIO_BITS <= (4*sizeof(AudioOutputStorage_t)), "Configured #define AUDIO_RATE_AS_LSHIFT 16 #define MICROS_PER_AUDIO_TICK 15 #else -#error Whoopsie, not LSHIFT defined for this audio rate. Please report and/or fix +//#error Whoopsie, not LSHIFT defined for this audio rate. Please report and/or fix #endif @@ -117,7 +115,9 @@ static_assert(MOZZI_AUDIO_BITS <= (4*sizeof(AudioOutputStorage_t)), "Configured #define CONTROL_RATE MOZZI_CONTROL_RATE #endif - - +/// Step 6: Some more checks that need to be at the end, because of requiring end of the foodchain headers +// TODO: Rather move this up again, and make AudioOutputStorage_t a primary config option +#include "../AudioOutput.h" +static_assert(MOZZI_AUDIO_BITS <= (8*sizeof(AudioOutputStorage_t)), "Configured MOZZI_AUDIO_BITS is too large for the internal storage type"); #endif diff --git a/internal/config_checks_avr.h b/internal/config_checks_avr.h index 8372cca81..5084f84a8 100644 --- a/internal/config_checks_avr.h +++ b/internal/config_checks_avr.h @@ -4,15 +4,15 @@ // NOTE: This step is actually required for all ports #if not defined(MOZZI_AUDIO_MODE) -#define MOZZI_OUTPUT_PWM +#define MOZZI_AUDIO_MODE MOZZI_OUTPUT_PWM #endif #if not defined(MOZZI_AUDIO_RATE) -#define 16384 +#define MOZZI_AUDIO_RATE 16384 #endif #if not defined(MOZZI_ANALOG_READ) -#define MOZZI_ANALOG_READ MOZZI_ANALOG_READS_STANDARD +#define MOZZI_ANALOG_READ MOZZI_ANALOG_READ_STANDARD #endif // Pins for regular PWM output @@ -58,10 +58,10 @@ MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PWM, MOZZI_OUTPUT_2PIN_PWM, MOZZI_OUTPUT_EXTERNAL_TIMED, MOZZI_OUTPUT_EXTERNAL_CUSTOM) -#if (MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PWM) +#if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PWM) MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_CHANNELS, MOZZI_MONO, MOZZI_STEREO) #endif -#if (MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_2PIN_PWM) +#if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_2PIN_PWM) MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_CHANNELS, MOZZI_MONO) #endif @@ -72,6 +72,7 @@ MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_RATE, 16384, 32768) MOZZI_CHECK_SUPPORTED(MOZZI_ANALOG_READ, MOZZI_ANALOG_READ_NONE, MOZZI_ANALOG_READ_STANDARD) MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_INPUT, MOZZI_AUDIO_INPUT_NONE, MOZZI_AUDIO_INPUT_STANDARD) +#include "../config/known_16bit_timers.h" #if defined(TIMER1_C_PIN) MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_PIN_1, TIMER1_A_PIN, TIMER1_B_PIN, TIMER1_C_PIN); #else diff --git a/internal/mozzi_macros.h b/internal/mozzi_macros.h index fdf4df4ea..ea692a3d0 100644 --- a/internal/mozzi_macros.h +++ b/internal/mozzi_macros.h @@ -26,7 +26,7 @@ MOZZI__INVALID_CONFIG_VALUE, MOZZI__INVALID_CONFIG_VALUE, MOZZI__INVALID_CONFIG_VALUE, MOZZI__INVALID_CONFIG_VALUE, MOZZI__INVALID_CONFIG_VALUE, MOZZI__INVALID_CONFIG_VALUE)) /// Complain if the given argument is not a power of two -#define MOZZI_CHECK_POW_2(X) static_assert((X & (X - 1)) == 0, #X " must be a power of two"); +#define MOZZI_CHECK_POW2(X) static_assert((X & (X - 1)) == 0, #X " must be a power of two"); /// Simply a way to check if X is Y, realiably, in case one or both are defined empty (such as because of a programmer's typo) #define MOZZI_IS(X, Y) (X == Y) diff --git a/mozzi_analog.cpp b/mozzi_analog.cpp index 927bc40a9..ae472dbbf 100644 --- a/mozzi_analog.cpp +++ b/mozzi_analog.cpp @@ -10,7 +10,6 @@ */ -#include "mozzi_config.h" #include "mozzi_analog.h" #include "hardware_defines.h"