Mozzi configuration options include details such as audio rate, number of audio channels (mono or stereo), output generation method and many others, where details on the available options differ between the different platforms (see Hardware and configuration), and may include additional options beyond those listed, here.
Configuring Mozzi is mostly done using various preprocessor definitions. This approach is used to move as much of the processing involved to compile time, in order to save Flash, RAM, and CPU use at runtime. This section lists various global options, but in addition, most ports allow additional hardware dependent configuration options. See Hardware and configuration.
Several configuration examples are provided in the "config" folder of the Mozzi sources. You may want to look at these, first. The general approach is as follows:
#define MOZZI_AUDIO_CHANNELS MOZZI_STEREO
This is the main include file in Mozzi.
This file keeps a list of named configuration values.
Alternatively, if a suitable configuration example exists, use:
#include <config/config_example_avr_stereo.h>
TODO: Fix and complete Doxygen coverage
◆ MOZZI_ANALOG_READ #define MOZZI_ANALOG_READWhether to compile in support for non-blocking analog reads.
This is enabled by default on platforms that support it, but may be disabled, explicitly, to save resources, or in order to implement custom read schemes (e.g. with IO multiplexing).
For simplicity, mozziAnalogRead() is always defined, but when MOZZI_ANALOG_READ s are disabled or unsupported, it simply relays to Arduino's regular analogRead(). It is thus quite recommended not to depend on mozziAnalogRead() when disabling this.
As a rough estimate (your numbers may differ a bit, depending on compiler version, etc.), on an ATMEGA328P (aka Arduino Uno), disabling analog reads saves 33 bytes of RAM and 340 bytes of FLASH. The performance savings are theorized to be neglegible, however.
Currently allowed values are:
Definition at line 169 of file mozzi_config_documentation.h.
◆ MOZZI_AUDIO_BITSOutput resolution of audio samples.
In most cases you should leave this value untouched (for the defaults that get applied, see Hardware and configuration . However, for MOZZI_AUDIO_MODE s MOZZI_OUTPUT_EXTERNAL_TIMED and MOZZI_OUTPUT_EXTERNAL_CUSTOM you way wish to customize the default value of 16 bits.
Definition at line 296 of file mozzi_config_documentation.h.
◆ MOZZI_AUDIO_BITS_PER_CHANNEL #define MOZZI_AUDIO_BITS_PER_CHANNEL ◆ MOZZI_AUDIO_CHANNELS #define MOZZI_AUDIO_CHANNELSThis 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.
Definition at line 106 of file mozzi_config_documentation.h.
◆ MOZZI_AUDIO_INPUT #define MOZZI_AUDIO_INPUTWhether to enable built in audio input feature.
This is not supported on all platforms, and on platforms that do support it may come with a considerable performance overhead. Don't enable, unless you need this.
Currently allowed values are:
Further reading and config: getAudioInput() MOZZI_AUDIO_INPUT_PIN
Definition at line 188 of file mozzi_config_documentation.h.
◆ MOZZI_AUDIO_INPUT_PIN #define MOZZI_AUDIO_INPUT_PINThis sets which analog input channel to use for audio input, if you have enabled MOZZI_AUDIO_INPUT, above.
Not all pins may be available for this, be sure to check the documentation for your platform.
Definition at line 197 of file mozzi_config_documentation.h.
◆ MOZZI_AUDIO_MODEConfigure how Mozzi outputs generated sounds.
Refer to the Hardware and configuration specific documentation for which modes are supported on your hardware, and further details!
Supported values:
TODO: Adding an R2R-DAC option would be cool, http://blog.makezine.com/2008/05/29/makeit-protodac-shield-fo/ , some discussion on Mozzi-users.
Definition at line 90 of file mozzi_config_documentation.h.
◆ MOZZI_AUDIO_PIN_1 #define MOZZI_AUDIO_PIN_1Only for MOZZI_AUDIO_MODE s MOZZI_OUTPUT_PWM and MOZZI_OUTPUT_2PIN_PWM: The IO pin to use as (first) audio output.
This must be attached to Timer1. When settings this, you alsso need to specify the output compare register responsible for this pin (either OCR1A or OCR1B).
Example:
#define MOZZI_AUDIO_PIN_1 TIMER1_B_PIN
#define MOZZI_AUDIO_PIN_1_REGISTER OCR1B
Equivalent definitions can be used to control the pin for the right audio channel (in stereo mode), or the low byte channel (in 2 Pin PWM mode):
#define MOZZI_AUDIO_PIN_2 [...]
#define MOZZI_AUDIO_PIN_2_REGISTER [the matching OCR]
#define MOZZI_AUDIO_PIN_1_LOW [...]
#define MOZZI_AUDIO_PIN_1_LOW_REGISTER [the matching OCR]
Definition at line 250 of file mozzi_config_documentation.h.
◆ MOZZI_AUDIO_RATEDefines the audio rate, i.e.
rate of samples output per second.
The default rate on the classis Arduino Uno is 16384 Hz, but can be increased to 32768 Hz, subject to the caveats, detailed below. For most other platforms 32678 Hz is the default, but even higher rates may be supported. Increasing the rate allows for better frequency response, but generally all affects achievable sample bitdepth (especially from PWM output). Also, of course, doubling the sample rate also 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.
It is highly recommended to keep the audio rate a power of two (16384, 32678, 65536, etc.), as some internal calculations can be highly be optimised for speed, this way.
Definition at line 129 of file mozzi_config_documentation.h.
◆ MOZZI_COMPATIBILITY_LEVEL #define MOZZI_COMPATIBILITY_LEVELMozzi generally tries to keep your old sketches working, but we continue to find new (and hopefully better) approaches to old problems.
Sometimes, keeping API compatibilty with the pre-existing solution may come with a smaller or larger penalty in terms of performance or code size. Therefore - if your sketch supports it - you may be able to get some minor benefit from disabling compatibility code.
Currently supported values are:
Definition at line 59 of file mozzi_config_documentation.h.
◆ MOZZI_CONTROL_RATE #define MOZZI_CONTROL_RATEControl rate setting.
Mozzi's MOZZI_CONTROL_RATE sets how many times per second updateControl() is called. MOZZI_CONTROL_RATE has a default of 64 Hz. It is useful to have MOZZI_CONTROL_RATE set at a power of 2 (such as 64,128,256 etc), to have exact timing of audio and control operations. Non-power-of-2 MOZZI_CONTROL_RATE can cause glitches due to audio and control events not lining up precisely. If this happens a power of two MOZZI_CONTROL_RATE might solve it.
Try to keep MOZZI_CONTROL_RATE low, for efficiency, though higher rates up to about 1000 can sometimes give smoother results, avoiding the need to interpolate sensitive variables at audio rate in updateAudio().
TODO: If a definition of MOZZI_CONTROL_RATE is detected, apply that with a warning.
Definition at line 148 of file mozzi_config_documentation.h.
◆ MOZZI_PWM_RATEOnly for MOZZI_AUDIO_MODE s MOZZI_OUTPUT_PWM and MOZZI_OUTPUT_2PIN_PWM.
On some platforms, the rate at which PWM signals are repeated may be higher than that at with audio signals are produced (i.e. MOZZI_AUDIO_RATE). E.g. for MOZZI_OUTPUT_PWM on the classic Arduino, the pwm defaults to 32768 while the audio rate defaults to 16384. The reasoning behind this is that 16384 Hz audio rate turned out to be te most useful compromise - in most casses - between output quality, and available computing power. However, output at that rate produced high-frequency whine, audible to some people, which could be mitigated by the higher PWM rate.
In other words, increasing this improves the signal quality at less cost than doubling the audio rate itself. However, increasing this too far will limit the dynamic resolution of the samples that can be written to the output pin(s): 2 ^ (output bits) * MOZZI_PWM_RATE cannot be higher than the CPU frequency!
Definition at line 212 of file mozzi_config_documentation.h.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4