Mozzi  version v2.0
sound synthesis library for Arduino
config_checks_template.h
1 /** NOTE Template only: Copy and adjust this file when adding a new port.
2  *
3  * More instructions on the process are to be found in MozziGuts_impl_template.hpp. Read those first!
4  *
5  * What this file shall do:
6  * 1) Set default values for certain configurable options. Try to stick to the defines already in use as much as possible,
7  * so configuration is consistent across ports.
8  * 2) Have some checks for configuration values that are not supported on this port
9  * 3) Document some details of your port
10  */
11 
12 /*
13  * config_checks_template.h
14  *
15  * This file is part of Mozzi.
16  *
17  * Copyright 2023-2024 Thomas Friedrichsmeier and the Mozzi Team
18  * NOTE: In your port, don't forget to update the above copyright notice!
19  *
20  * Mozzi is licensed under the GNU Lesser General Public Licence (LGPL) Version 2.1 or later.
21  *
22 */
23 
24 /** NOTE: If your port doesn't support MOZZI_OUTPUT_2PIN_PWM, add this include to make compilation of HIFI examples pass on the github runner */
26 /** NOTE: All ports need to provide a default for this */
27 #if not defined(MOZZI_AUDIO_MODE)
28 # define MOZZI_AUDIO_MODE MOZZI_OUTPUT_PWM
29 #endif
30 /** NOTE: And all ports should allow only supported output modes. Note that MOZZI_OUTPUT_EXTERNAL_TIMED and MOZZI_OUTPUT_EXTERNAL_CUSTOM
31 are usually trivial to implement, so we'll assume your port allows them, too: */
32 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PWM, MOZZI_OUTPUT_EXTERNAL_TIMED, MOZZI_OUTPUT_EXTERNAL_CUSTOM)
33 
34 /** NOTE: All ports need to provide a default for this. 32768 is reasonable on most modern MCUs, but 16384 may be useful for weaker MCUs. */
35 #if not defined(MOZZI_AUDIO_RATE)
36 # define MOZZI_AUDIO_RATE 32768
37 #endif
38 
39 /** NOTE: *If* your port has an implementation for asynchronous analog reads, these shall be enabled by default. */
40 #if not defined(MOZZI_ANALOG_READ)
41 # define MOZZI_ANALOG_READ MOZZI_ANALOG_READ_STANDARD
42 #endif
43 /** NOTE: *Otherwise* you may additionally document that as not-yet-supported like so: */
44 // MOZZI_CHECK_SUPPORTED(MOZZI_ANALOG_READ, MOZZI_ANALOG_READ)
45 
46 /** NOTE: This should be set to whichever resolution (in bits) mozziAnalogRead() returns values in by default in your implementation.
47  * mozziAnalogRead<bits>() will shift the return value accordingly. Generally you will set this to the default hardware resolution for this platform.
48  *
49  * @em Optionally, you could to set this to the user configurable MOZZI_ANALOG_READ_RESOLUTION (if it has been defined), and configure your ADC reads,
50  * accordingly, avoiding the extra shift operation:
51  *
52  * @code
53 #ifdef MOZZI_ANALOG_READ_RESOLUTION
54 #define MOZZI__INTERNAL_ANALOG_READ_RESOLUTION MOZZI_ANALOG_READ_RESOLUTION
55 #define MOZZI__IMPL_SET_ANALOG_READ_RESOLUTION
56 #else
57 #define MOZZI__INTERNAL_ANALOG_READ_RESOLUTION 16
58 #endif
59 
60 [...]
61 
62 //inside MozziGuts_impl_MPLATFORM, function setupMozziADC():
63 #ifdef MOZZI__IMPL_SET_ANALOG_READ_RESOLUTION
64 analogReadResolution(MOZZI_ANALOG_READ_RESOLUTION);
65 #endif
66  * @endcode
67 */
68 #define MOZZI__INTERNAL_ANALOG_READ_RESOLUTION 10
69 
70 /** NOTE: Example for additional config options depending on a specific output mode: */
71 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_INTERNAL_DAC)
72 # if !defined(MOZZI_AUDIO_PIN_1)
73 # define MOZZI_AUDIO_PIN_1 5
74 # endif
75 /** NOTE: All ports need to provide a default for this, for all audio modes _except_ for the external ones: */
76 # if !defined(MOZZI_AUDIO_BITS)
77 # define MOZZI_AUDIO_BITS 10
78 # endif
79 /** NOTE: If only mono is supported in this output mode: */
80 # include "disable_stereo_on_github_workflow.h" // This allows stereo sketches to compile (in mono) in automated testing builds.
81 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_CHANNELS, MOZZI_MONO)
82 #endif
83 
84 
85 /** NOTE: You may also set further, implementation-specific defines, here. E.g. BYPASS_MOZZI_OUTPUT_BUFFER. Defines that are purely
86  * specific to your port (i.e. only needed inside MozziGuts_impt_YOURPLATFORM.h, should be #undef'ed at the end of that file. */
87 
88 
89 /** NOTE: The following is an example documentation for your port. In order not to end up in the real documentation, the comment starts
90  * with "/*", only. Change that to "/**" to enable documentation to be extracted. */
91 
92 /* @ingroup hardware
93  * @page hardware_MYPORT Mozzi on MYPORT architecture based boards (e.g. MOST PROMINENT BOARD)
94  *
95  * Port added by YOUR_NAME.
96  *
97  * @section MYPORT_status Status of this port and usage notes
98  * This port has been tested on BOARD A, BOARD B, but is expected to work on other boards using this family of MCUs, too.
99  * The default MOZZI_AUDIO_RATE is set to 32678 Hz. Asynchronous analog reads are not yet implemented, so be careful
100  * not to use mozziAnalogRead() too much. Also @ref MOZZI_AUDIO_INPUT is not available.
101  *
102  * When connecting external circuitry, keep in mind that the GPIO pins on this CPU are rated at a max of 3 mA. Be careful
103  * not to over-stress them. It is further recommended not to make use of feature X when using Mozzi, as it will
104  * introduce considerable noise into the audio.
105  *
106  * Also, something else to keep in mind about this port.
107  *
108  * @section MYPORT_output_modes Output modes
109  * The following audio modes (see @ref MOZZI_AUDIO_MODE) are currently supported on this hardware:
110  * - MOZZI_OUTPUT_EXTERNAL_TIMED
111  * - MOZZI_OUTPUT_EXTERNAL_CUSTOM
112  * - MOZZI_OUTPUT_INTERNAL_DAC
113  *
114  * The default mode is @ref MYPORT_internal_dac , meaning, only boards with an inbuilt DAC are covered by default
115  * (you could stil use one of the external output modes, however).
116  *
117  * @section MYPORT_internal_dac MOZZI_OUTPUT_INTERNAL_DAC
118  * Output resolution is 10 bits by default, and goes to pin DAC0. Hardware timer 1 is claimed by Mozzi.
119  * Only mono output is supported. Within the hardware limits of your board, you can configure the following:
120  *
121  * @code
122  * #define MOZZI_AUDIO_PIN_1 ... // default is DAC0
123  * #define MOZZI_AUDIO_BITS ... // default is 10
124  * @endcode
125  *
126  * @section MYPORT_external MOZZI_OUTPUT_EXTERNAL_TIMED and MOZZI_OUTPUT_EXTERNAL_CUSTOM
127  * See @ref external_audio
128 */