You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#error This header should be included for RP2040, only
6
+
#endif
7
+
8
+
9
+
// AUDIO output modes
10
+
#definePWM_VIA_BARE_CHIP 1 // output using one of the gpio of the board
11
+
#defineEXTERNAL_DAC_VIA_I2S 2 // output via external DAC connected to I2S (PT8211 or similar)
12
+
13
+
//******* BEGIN: These are the defines you may want to change. Best not to touch anything outside this range. ************/
14
+
#defineRP2040_AUDIO_OUT_MODE PWM_VIA_BARE_CHIP
15
+
//******* END: These are the defines you may want to change. Best not to touch anything outside this range. ************/
16
+
17
+
18
+
#if (RP2040_AUDIO_OUT_MODE==PWM_VIA_BARE_CHIP)
19
+
#defineAUDIO_CHANNEL_1_PIN 0
20
+
#if (AUDIO_CHANNELS>1)
21
+
// Audio channel pins for stereo or HIFI must be on the same PWM slice (which is the case for the pairs (0,1), (2,3), (4,5), etc.
22
+
#defineAUDIO_CHANNEL_2_PIN 1
23
+
#endif
24
+
25
+
// The more audio bits you use, the slower the carrier frequency of the PWM signal. 11 bits yields ~ 60kHz on a 133Mhz CPU (which appears to be a reasonable compromise)
26
+
#defineAUDIO_BITS 11
27
+
#endif
28
+
29
+
#if (RP2040_AUDIO_OUT_MODE==EXTERNAL_DAC_VIA_I2S)
30
+
// ****** BEGIN: These are define you may want to change. Best not to touch anything outside this range. ************/
31
+
#defineBCLK_PIN 20
32
+
#defineWS_PIN (pBCLK+1) // CANNOT BE CHANGED, HAS TO BE NEXT TO pBCLK
33
+
#defineDOUT_PIN 22
34
+
#defineLSBJ_FORMAT false // some DAC, like the PT8211, use a variant of I2S data format called LSBJ
35
+
// set this to true to use this kind of DAC or false for plain I2S.
36
+
#defineAUDIO_BITS 16 // available values are 8, 16, 24 (LEFT ALIGN in 32 bits type!!) and 32 bits
37
+
// ****** END: These are define you may want to change. Best not to touch anything outside this range. ************/
38
+
39
+
#defineBYPASS_MOZZI_OUTPUT_BUFFER true
40
+
41
+
// Configuration of the I2S port, especially DMA. Set in stone here as default of the library when this was written.
42
+
// Probably do not change if you are not sure of what you are doing
43
+
#defineBUFFERS 8 // number of DMA buffers used
44
+
#defineBUFFER_SIZE 256 // total size of the buffer, in samples
Copy file name to clipboardExpand all lines: AudioConfigSTM32.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@
22
22
// The more audio bits you use, the slower the carrier frequency of the PWM signal. 10 bits yields ~ 70kHz on a 72Mhz CPU (which appears to be a reasonable compromise)
/** Conversion to int operator: If used in a mono config, returns only the left channel (and gives a compile time warning). */
92
-
inlineoperatorAudioOutput_t() const __attribute__((deprecated("Sketch generates stereo output, but Mozzi is configured for mono. Check mozzi_config.h."))) { return _l; };
94
+
#if (AUDIO_CHANNELS != STEREO)
95
+
/** Conversion to int operator: If used in a mono config, returns only the left channel (and gives a compile time warning).
96
+
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
97
+
using StereoOutput in a mono config, is not intended. */
98
+
inline AudioOutput_t portable() const __attribute__((deprecated("Sketch generates stereo output, but Mozzi is configured for mono. Check mozzi_config.h."))) { return _l; };
93
99
#endif
94
100
AudioOutputStorage_t l() const { return _l; };
95
101
AudioOutputStorage_t r() const { return _r; };
96
102
/** @see MonoOutput::clip(). Clips both channels. */
template<typename A, typename B> staticinline StereoOutput fromAlmostNBit(A bits, B l, B r) { returnStereoOutput(SCALE_AUDIO_NEAR(l, bits), SCALE_AUDIO_NEAR(r, bits)); }
111
113
private:
112
114
AudioOutputStorage_t _l;
113
115
AudioOutputStorage_t _r;
@@ -130,9 +132,11 @@ struct StereoOutput {
130
132
structMonoOutput {
131
133
/** Construct an audio frame from raw values (zero-centered) */
132
134
MonoOutput(AudioOutputStorage_t l=0) : _l(l) {};
133
-
#if (STEREO_HACK == true)
134
-
/** Conversion to stereo operator: If used in a stereo config, returns identical channels (and gives a compile time warning). */
135
-
inlineoperatorStereoOutput() const __attribute__((deprecated("Sketch generates mono output, but Mozzi is configured for stereo. Check mozzi_config.h."))) { returnStereoOutput(_l, _l); };
135
+
#if (AUDIO_CHANNELS > 1)
136
+
/** Conversion to stereo operator: If used in a stereo config, returns identical channels (and gives a compile time warning).
137
+
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
138
+
using StereoOutput in a mono config, is not intended. */
139
+
inline StereoOutput portable() const __attribute__((deprecated("Sketch generates mono output, but Mozzi is configured for stereo. Check mozzi_config.h."))) { returnStereoOutput(_l, _l); };
/** Construct an audio frame a zero-centered value known to be in the N bit range. Appropriate left- or right-shifting will be performed, based on the number of output
147
151
* bits available. While this function takes care of the shifting, beware of potential overflow issues, if your intermediary results exceed the 16 bit range. Use proper
148
152
* casts to int32_t or larger in that case (and the compiler will automatically pick the 32 bit overload in this case) */
/** Construct an audio frame from a zero-centered value known to be in the 8 bit range. On AVR, STANDADR or STANDARD_PLUS mode, this is effectively the same as calling the
153
155
* constructor, directly (no scaling gets applied). On platforms/configs using more bits, an appropriate left-shift will be performed. */
0 commit comments