Mozzi sound synthesis library for Arduino

NEWS
get the latest version from https://sensorium.github.io/Mozzi/

release: v2.0.1
- Fix compilation with configuration option MOZZI_AUDIO_INPUT
- Fix compilation with ATMEGA328PB CPUs
- Fix some erroneous compilation warnings

release: v2.0.0
- This release is *not* 100% source compatible to earlier versions of Mozzi. Most sketches will continue to compile,
  but with warnings. Some will need adjustments to keep working. See https://sensorium.github.io/Mozzi/learn/porting/ .
  If porting is not an option, install an earlier (1.x) version of Mozzi, or use the "Mozzi_1" branch in git.
- Now depends on FixMath library for enhanced fixed point arithmetic (which is actually spin-off originating in the Mozzi project)
- Explicitly specify bit depth for "int" or "long" in several places, for better cross-platform consistency
- Restructured configuration options for more consistency across platforms, and easier customization.
  There is no longer a central mozzi_config.h file, but rather config options can be customized using
  #defines at the top of a sketch.
- Changed licence to LGPL version 2.1 or later

release v1.1.2
- new partial port of the Arduino Uno R4
- new partial port of the Arduino Giga by Thomas Friedrichsmeier & Thomas Combriat
- new (partial) port to the STM32duino core by Thomas Friedrichsmeier
- compilation fixes to old (libmaple-based) STM32 core

release v1.1.0
- new synth classes (and examples) by Tom Combriat @tomcombriat:
	- Wavefolder
	- MetaOscil
	- MultiResonantFilter


release v1.1.0rc1 (not actually "released", just the Github code around 2019 onwards.)
- Initial RP2040 port added by Thomas Friedrichsmeier
	Hardware specific notes are on the Mozzi main web page.
- Initial Teensy 4.X port added by Tom Combriat
- Code reorganised to split most hardware specific code into dedicated files
- STEREO_HACK is deprecated in favor of AUDIO_CHANNELS
- updateAudio() should be slightly rewritten for portability across different configurations and boards
	- refer to the MonoOutput() and StereoOutput() classes for more detail
- EXTERNAL_AUDIO_OUPUT allows to integrate external DACs, easily
- STM32(duino) and ESP8266 ports have been added by Thomas Friedrichsmeier, ESP32 port by Dieter Vandoren and Thomas Friedrichsmeier.
	Thomas has provided hardware specific notes on the Mozzi main web page.
- CONTROL_RATE no longer has to be a power of 2,
	and Mozzi no longer takes over Timer 0 for control interrupts.
	Thanks to Thomas Friedrichsmeier for this innovation.
- Other changes to MozziGuts.cpp, .h,
	- pauseMozzi() and unPauseMozzi() are obsolete.  Added stopMozzi().
		Use startMozzi() from now on instead of unPauseMozzi().
	- Removed backupMozziTimer functions, not required anymore.
- Removed examples>02.Control>Pause, added Stop_Start.
- Fixed errors in ADSR examples


release v1.0.4
- EventDelay.h and Metronome.h moved stop() from Metronome to EventDelay, and Metronome's ready() to EventTimer.
	This allows EventTimer to be stopped, and Metronome inherits from there.
- globally removed "defined(TEENSYDUINO)  || defined(TEENSYDUINO" typo, replaced with "defined(TEENSYDUINO)-
- MozziGuts.cpp changed line 277 to
	adc->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED); // could be HIGH_SPEED, noisier
	to keep up with Teensy changes

release v1.0.3rc7
- fixed STEREO_HACK code and example
- added Stereo_Hack_pan example demonstrating constant power panning

release v1.0.3rc6
-MozziGuts.cpp line 444: changed setPeriodMicroSeconds to setPeriodCPUCycles so HIFI actually works this time...


release v1.0.3rc5
-MozziGuts.cpp line 444: changed setPeriod to setPeriodMicroSeconds to match Mozzi's modified FrequencyTimer2


release 2016-12-11-17:03
release v1.0.3rc4
- removed stray FrequencyTimer files from main folder, which stopped anything compiling...!
- small fixes in rc3


release v1.0.3rc2

- Teensy now compiles, bit of a hack added
	|| defined(TEENSYDUINO)
	to all Teensy conditional compile lines like this:
	#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(TEENSYDUINO)  // teensy 3, 3.1
- examples, removed commented ADC.h line from all examples, Teensy doesn't seem to need it anymore


release v1.0.3rc1

Mostly bug fixes and maintainance, with update to suit Arduino 1.5+.  Though tests show the 1.0.5 IDE still produces faster code than any speed optimisation levels compiled with the newer versions.
- added library.properties for Arduino 1.5+
- MozziGuts.cpp and .h, and mozzi_config.h: added STEREO_HACK config option, set it to true to try stereo output, also added Stereo_Hack exammple
- README - updated install instructions
- examples/Mozzi_Midi_Input, added note about rx pin for midi in rather than tx as shown on Arduino page.
- ADSR.h - now IDLE phase will always return 0.
- included ADC.h for Teensy 3+ in mozzi_analog.h and removed it from sketches - not sure why this didn't work before (maybe <> instead of "").
- python scripts sin1024_uint8.py and sin8192_uint8.py, changed broken int16_t casts to int, Might have accidentally changed in a global search/replace.
- examples - changed Sinwave_PWM_leds_HIFI to Sinwave_PWM_leds, can't see any need for extra confusion of HFI
- examples - Detuned_Oscil_Wash - added note about compiling for speed, and that Arduino 1.0.5 still produces faster code.

version_2015-05-11-20:23

aka v1.0.2

First (slightly edited) versioned release using GitHub release process.
Warning: This release and all previous versions of Mozzi run slow when using Arduino IDE versions greater than 1.0.5, at least on OSX, causing glitches on many of the included examples. Simple examples run OK, but until this is resolved, Arduino 1.0.5 is recommended.

- Tweaks and fixes, a couple of new simple demos..
- Fixed/updated python script for converting wavetables, fixed name back to char2mozzi.py
- Updated MIDI examples for newer MIDI library.
- Updated OverSample.h to take an additional termplate parameter to allow different numeric types.
- Removed library.properties file until the library folder stucture is updated to match the new Arduino library form, as it stopped it installing in new IDEs.



version_2014-08-09-14:15

Teensy 3.1 port, test release.


Extra libraries required:

- Timer library for Teensy 3.0 by Daniel Gilbert, from https://github.com/loglow/IntervalTimer

- ADC library by Pedro Villanueva, from http://github.com/pedvide/ADC.


Some of the differences for Teensy 3.1 which will affect users include:

- Audio output is on pin A14/DAC, in STANDARD or STANDARD_PLUS audio modes - these are identical on Teensy 3.1, as
	the output is via DAC rather than PWM.

- Output is 12 bits in STANDARD and STANDARD_PLUS modes, up from nearly 9 bits for Atmel based boards.
	HIFI audio, by summing two output pins, is not available on Teensy 3.1.

- #include <ADC.h> is required at the top of every Teensy 3.1 sketch.  The examples come with this commented out, for Arduino compatibility.
	Non-blocking mozziAnalogRead() is implemented using the excellent ADC library
	created by Pedro Villanueva, which be downloaded from http://github.com/pedvide/ADC.
	The ADC library is only being used very simply in the initial Mozzi port, but it opens the way to fine control
	of ADC in future development.Also, remember Teensy 3 analog input range is 3.3v, not 5v.

- uint8_t and int8_t are used instead of unsigned char and char, to work with Teensy 3.1, where char etc. don't work.

- Serial baud rate for monitoring in the IDE needs to be set to 9600 to work with Teensy 3.1.
	This slow rate causes audio glitches.

- twi_nonblock code for non-blocking I2C is not compatible with Teensy 3.1.
	twi_nonblock was authored by Marije Baalman in this fork https://github.com/sensestage/Mozzi.


Various other changes which affect the library in general:

- Changed license from GPL3 to Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

- ADSR.h

	- next() now returns unsigned char instead of unsigned int

	- added functions to set ADSR times in update steps, eg. setAttackUpdateSteps(unsigned int steps), etc.,
	for finer-grained control

- SampleHuffman.h - now plays correctly from beginning when start() used before finished playing previous cycle.

- Re-included RCpoll.h and examples>03.Sensors>RCpoll, for capacitive sensing.
	They have been included before, but disappeared somewhere along the way.

- Added PDResonant.h, and examples>06.Synthesis>PDResonant.  PDResonant is a simple midi intrument which demonstrates
	Phase Distortion used to create a sweeping resonant filter effect, based on
	https://en.wikipedia.org/wiki/Phase_distortion_synthesis.

- mozzi_fixmath.h - added Q15n16_to_Q8n0()

- Fixed broken link in Sensor examples to http://sensorium.github.io/Mozzi/learn/introductory-tutorial/

- Moved Arduino timer libraries into "utility" folder and added conditional compilation to hide them from Teensy 3.1 compilation.

 - Removed cpu speed warning from MozziGuts.h



version_2014-04-20-15:06

- MozziGuts.cpp
	- all examples (exept HIFI) now run in STANDARD_PLUS mode, due to improved performance with new outbut buffer code (added CircularBuffer.h)
	- fixed error in audio input code (was output_gap instead of input_gap)
	- modified mozziMicroseconds() to work with new buffer code.
	- changed audio input to use new CircularBuffer code
- MozziGuts.h - changed "Mozzi expects a cpu clock speed of 16MHz!" error message to a warning,
		since there are reports of people using Mozzi on 8MHz boards (though I reckon it would sound pretty rough).
- ADSR.h added template parameter LERP_RATE, increasing the flexibility of ADSR use, so both update() and next()
	can now be used in updateAudio() or updateControl().
- added examples/07.Envelopes/ADSR_Control_Rate_Envelope and examples/07.Envelopes/ADSR_Audio_Rate_Envelope, replacing ADSR_Envelope
- added/fixed IntMap.h, a fast integer replacement for Arduino map(), using some compile-time calculations.
- added examples/12.Utilities/IntMap_test
- changed examples/06.Synthesis/FMSynth_HIFI to FMSynth_32k_HIFI, higher audio rate reduces audio aliasing.
- changed examples/01.Basics/Table_Resolution to switch/case in updateAudio() instead of lots of arithmetic... still has a ticking sound for some reason.



version_2014-03-13-14:09

- MozziGuts.cpp/h,mozzi_config.h - Added STANDARD_PLUS audio mode.   This is now the default audio mode.
	Just like STANDARD, but with 32768Hz PWM rate, so the whine which some people hear in STANDARD mode is now out of hearing range.
	A notch filter is not required for STANDARD_PLUS output.
	STANDARD_PLUS introduces a slight performance penalty over STANDARD mode, but works for most of the Mozzi demo examples.
	I recommend it for general use, with a fall back to STANDARD for more demanding sketches.
	HIFI mode is unchanged, but is being revised to address broad-spectrum noise/distortion issues in this mode.
- TimerOne.h - changed initialize(usecs) to choice of initializeMicroseconds(usecs) or initializeCPUCycles(cycles),
	providing the finer resolution required for the PWM rate increase.
- FrequencyTimer2.cpp - changed setPeriod to setPeriodMicroSeconds() and added setPeriodCPUCycles().
- examples/02.Control/Line_Gliss_Double_32k_HIFI - changed "warmtriangle" wave to saw and changed one of the oscils up an octave.  Molto Aggressivo.  Almost.
- examples/10.Audio_Filters/StateVariableFilter - changed some floats which were supposed to be ints
- StateVariable.h - removed a clicking sound heard in some situations, thanks to diligent problem-finding by qwester1 on github.  Cheers qwester1.
  The centre frequency calculation is still extremely approximate.  Needs more work.


version_2013-09-12-15:15

- EventDelay.h - no longer a template class, and doesn't need an UPDATE_RATE parameter.
	Breaking old sketches again! Just get rid of the EventDelay template part in sketches.
	Now sets an internal deadline and checks the time passed in audio ticks instead of counting down.
- added SampleHuffman.h, a sample player for samples encoded with Huffman compression,
	based on an Arduino sketch by Thomas Grill, 2011 http//grrrr.org.
	- added extras/python/audio2huff.py,
	a script to convert sounds to compressed tables for the player, by Thomas Grill (Modified by TB for Mozzi)
	- added examples/08.Samples/SampleHuffman_Umpah.
- added Metronome.h, a repeating EventDelay.
	- added examples/02.Control/Metronome_SampleHuffman
- added examples/03.Sensors/Light_Temperature_Multi_Oscil, mapping Thermistor and LDR readings to control and audio oscillator frequencies.
- added examples/03.Sensors/Light_Temperature_Detuned, mapping Thermistor and LDR readings to 14 audio oscils
- added OverSample.h, for increased resolution of analog inputs.
	- added examples/05.Control_Filters/Thermistor_OverSample to demonstrate OverSample object.
- ControlDelay.h - changed default storage type from int8_t to int16_t.
- Changed docs regarding components for HIFI mode, 1M resistor is now 499k (or two 1M in parallel).
	Also added contribution from Standuino group on forum about component values for direct headphone output,
	39 ohm, 4.99k (or two 10k in parallel) and 470nF filter capacitor.


version_2013-08-25-18:38

- mozzi_analog.h - Much simpler, better analog input.  Now there's just mozziAnalogRead(pin).
	Sorry about breaking your sketches, again.
	mozziAnalogRead completely replaces the arduino analogRead, and analogRead is no longer able to be used with Mozzi.
	No setup is required for mozziAnalogRead, unless you want audio input, which is set in mozzi_config.h as before.
	You can still use setupFastAnalogRead(speed) if you want faster than mozzi's default,
	which is automatically set if you don't do anything.  See the documentation if you want this.
	If you specially need analogRead for some reason (and you're not using audio input), you can comment out a
	line in MozziGuts.cpp, in the startMozzi function, where it says setupMozziADC().
- All example sketches using analog reads are updated, or removed where no longer relevant.
- examples/04.Analog_Input changed to 04.Audio_Input
- examples/envelopes/ADSR_Envelope - now plays random envelopes as a more thorough test/demo.
- add examples/envelopes/ADSR_Envelope_x2 - shows an additive sound combining 2 oscillators with individual envelopes.
- Sample.h - added linear interpolation as optional template parameter, eg.:
	Sample <SAMPLE_NUM_CELLS, MOZZI_AUDIO_RATE, INTERP_LINEAR> aSample(SAMPLE_DATA);
	The default parameter is INTERP_NONE.
- removed examples/08.Samples/Sample_Offset too horrible
- added examples/08.Samples/Sample_Scrub...uses interpolation/smoothing at different scales
- Smooth.h - added operator method as an alternative to next() so you can use
	mySmooth(input-value) instead of mySmooth.next(input-value), if you want.
- mozzi_midi.h, .cpp - changed return type from uint16_t to int16_t for mtof(uint8_t midi_note), mtof(int16_t midi_note),
	to suit Oscil::setFreq()
- added/corrected references to examples in docs


version_2013-07-29-18:09

- IMPORTANT: renamed RecentAverage.h to RollingAverage.h.  Update sketches accordingly.
- mozzi_analog.h
	- added the ability to sample audio and control rate analog inputs at the same time
	- added options for setupFastAnalogRead(), default is FAST (adc clock div main clock by 16, same as previously),
		and setupFastAnalogRead(FASTER) and FASTEST for divide by 8 and divide by 4.  These faster rates risk being less accurate
	(see docs for setupFastAnalogRead), but FASTER (or FASTEST) is required for audio input with control inputs at the same time.
- added examples/04.Analog_Input/Audio_and_Control_Input
- added examples/04.Analog_Input/Audio_Input_with_Knob_Filter
- removed examples/04.Analog_Input/Audio_Input_with_Filter_Control
- RollingAverage.h - change uint8_t index to uint16_t and same for num_readings_as_rshift, so more than 255 items can be averaged
- added audioTicks(), returns how many audio samples have been played since the program started - this will overflow less often than mozziMicros().
- mozziMicros() was wrong, audioticks/us-per-tick... fixed, now audioticks*us-per-tick
- added Stack.h, a simple stack class used internally for reading analog control inputs via adcReadAllChannels().
- added RollingStat.h, which calculates an approximation of the variance and standard deviation for a window of recent inputs,
	for doing things with sensor inputs.


version_2013-07-13-16:36

- Added extras folder and moved non-code files to there.
- Tried migrating code into a src folder structure for new library spec 1.5, but doesn't work yet so moved it back to top folder.
- Fixed circuit description in Sinewave_PWM_leds_HIFI example.
- Replaced ((progmem)) in tables and samples with ((section(".progmem.data"))) to work around bogus compiler warning,
	see http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=100009
	If Arduino's version of avr-gcc advances, this will eventually become unnecessary.
- Added compiler warning to remind whether AUDIO_MODE is STANDARD or HIFI, might help debugging.
- mozzi_fixmath.h
	- added Q7n0_to_Q15n16(Q7n0 a), Convert Q7n0 int8_t to Q15n16 fixed point.
	- added Q7n8_to_Q15n16(Q7n8 a), Convert Q7n8 fix to Q15n16.
	- added Q7n8_mult(Q7n8 a, Q7n8 b)


version_2013-07-07-17:51
- had #define AUDIO_MODE HIFI as default - changed back to #define AUDIO_MODE STANDARD,
	it would have made most examples sound bad without any warning.  sorry
- new versioning: a timestamp


_Version_0.01.2e_
- bugfixes.  Should have tested properly!
- Fixed ADSR compile problem due to mistakes while editing docs.
- Fixed Table_Resolution compile prob due to sin table error
- Added AutoMap.h, for mapping unpredictable sensor input ranges to a set output range
	- demos of AutoMap in examples/sensors/Knob_LDR_x2_WavePacket and a couple of others in sensors/


Version_0.01.2d
- mozzi_analog.cpp - fixed show-stopping typo (!= instead of |=)in adcStartConversion() and adcStartConversion(pin).
- added WavePacketSample.h, a WavePacket which allows a custom table for audio source (limited at the moment to 8192 samples)
	- added samples/raven_arh_int8.h to test WavePacketSample with.
- lots of minor documentation fixes, new layout.
- re-arranged website with some docs more easy to find.


Version_0.01.2c
- removed Ead.cpp, condensed to Ead.h
- mozzi_analog.h changed all xorshift96()>>16's to xorshift96() & 0xFFFF and all /256's to >>8
- added ControlDelay(), the same as AudioDelay() but for control values.
- added AutoRange(), for keeping a running calculation of sensor input range (should also have a variable timespan/fading memory).
- tweaked twi_nonblock.cpp and twi_nonblock.h to get rid of some compile warnings about return values.
	Madetwi_initiateReadFrom() and twi_initiateWriteFrom() return their error states
	and made twi_continueReadFrom() and twi_continueWriteFrom() return void.
- numbered the Examples category folders to give more sense of organisation and progression
- added Examples > Mozzi > _04_analog_input > Audio_Input, a minimal test of Mozzi audio input.
- added Examples  > Mozzi > _02_control > Control_Echo_Theremin, demonstrating ControlDelay()
- repaired hack for Teensy 2 in mozzi_analog.h so it compiles again
- moved default CONTROL_RATE definition to MozziGuts.h, it doesn't need to be in
    a config file if you can change it in a sketch.
- changed sin1024_int8.h table to use full range signed 8 bit values - it was scaled down slightly for a forgotten project
- removed samples/TJBAnalogDisk and samples/thumbpiano, these will be available as a separate "Mozzi_Extras" download.
- removed samples/Bamboo1 and changed samples/Samples sketch to use samples/bamboo


Version_0.01.2b
- fixed some docs
- added thumbpiano samples


Version_0.01.2a
- Added Examples>Mozzi>communication>Sinewave_HIFI_PWM_leds, to show
	non-blocking pwm for any pins without disprupting audio.
- Added Examples>Mozzi>sensors directory with several basic examples
	for modifiying sound with light dependent resistors, potentiometers, piezos and switches.
	These go with a tutorial on the main Mozzi site http://sensorium.github.io/Mozzi/Mozzi_Introductory_Tutorial.pdf
	Updated from previous unannounced inclusion which had lots of errors...


Version_0.01.1zzzz
- fixed indent error in all python scripts (error introduced in last release)
- removed a wierd file link which stopped installation working
- added some samples from a collection of analog bass samples by T.J.Baker,
	from Amiga aminet archive sample disk TJBAnalogDisk.lha.
	Samples are in Mozzi/samples/TJBAnalogDisk.
	There are wav files to audition and converted versions for Mozzi.
	More of the like to come...


Version_0.01.1zzz
- Modified Flexitimer2.cpp so ATMEGA32U4 processor based boards work again (Leonardo,Teensy2.0).
- Included twi_nonblock.h and twi_nonblock.cpp, non-blocking two wire I2C code by Marije Baalman,
	with Examples>Mozzi>Communication>TwoWire_Read_ADXL345.  Not documented yet.
- Sample.h
	- added isPlaying(), true if the sample is playing
	- fixed rangeWholeSample() so startpos = 0
- changed all instances of #include Arduino.h to conditional include WProgram.h for older versions of the IDE..not tested
- Added Examples>Mozzi>communication>Mozzi_Processing_Serial,
	demonstrates the sending data from the computer to the Arduino board.
- Added Examples>Mozzi>control>RCpoll, demonstrates reading a resistive sensor on digital pin without blocking audio.



Version_0.01.1zz
- Added ReverbTank, a reverb which sounds like the inside of a tin can, and an example ReverbTank_STANDARD
- AudioDelay
	- added template parameter for signal type, to allow ints as well as the default int8_t type.
	- next() now returns only delayed signal, so mixing can be flexible and is done in the sketch
- AudioDelayFeedback
	- repaired a few bugs. (I hope)
	- added next(int8_t input) which was missing for LINEAR interpolated delays



Version_0.01.1z
- Phasor - changed setFreq(uint16_t) to setFreq(int16_t), old sketches will need updating
- Reorganised examples into topic subdirectories and removed numbers
- MozziGuts.cpp
	- Added pauseMozzi() - Stops audio and control interrupts and restores the timers to the values they had before Mozzi was started.
	This will re-enable the Arduino time functions delay() and delayMicroseconds() while paused.
	- Added unPauseMozzi(), allowing Mozzi to continue again after being paused.
	- added mozziMicros(), a replacement for Arduino micros().
- mozzi_config.h - MOZZI_AUDIO_RATE is now a configuration option which can be defined as 16384 (default) or 32768.
	16384 obviously allows more time for each sample to be calculated, but the higher rate may
	be useful in some situations (experimental).
- AudioDelayFeedback.h
	- added optional template parameters for LINEAR (default) or ALLPASS interpolation.
	- added examples/delays/AudioFeedbackDelayAllpass example.
- Added WavePacket.h, a synthesis unit based on Miller Puckette's wavepacket example in Pure Data.
	- added examples/synthesis/WavePacket_Double and WavePacket_Single examples
- mozzi_fixmath.h
	- added Q24n8_to_Q16n0(Q24n8 a)
	- added Q15n16_to_Q23n8(Q15n16 a)
	- added Q15n0_FIX1
- tables/cosphase8192_int8.h - made data full range -128 to 127, was less for some reason
- Examples -
	- added examples/control/Pause demonstrating pauseMozzi() and unPauseMozzi()
	- added examples/control/Mozzi_Processing_Serial showing serial communication used to control Mozzi (from Processing)
- Added DCfilter.h, a DC-blocking filter useful for highlighting changes in control signals, and added m_42_DCfilter example.
- Oscil.h - consolidated some shift values together in setFreq_Q16n16 and setFreq_Q24n8
- Merged LowPassFilter.cpp into LowPassFilter.h
- changed Sample_Offset example - now much more irritating!



Version_0.01.1y

Important: sketches written before this version of Mozzi will need updating to remove
	(uint16_t) casts or "u" after integer arguments to:
	- Oscil::setFreq(uint16_t) changed to setFreq(int16_t)
	- Sample::setFreq(uint16_t) changed to setFreq(int16_t)
- fixed a compile error for HIFI mode (thanks to Thomas for pointing this out)
- Added HIFI tests m_01b_Sinewave_HIFI, m_03b_FMsynth_HIFI and m_05b_AMsynth_HIFI.
	The AMsynth example is the only one which actually has higher resolution than its STANDARD version.
- CONTROL_RATE is now set to a default value of 64 in Mozzi/mozzi_config.h.
	You can still define it in your sketch, or you change the default in the config file.
- StartMozzi() can now be used without an argument.  It will use the default CONTROL_RATE
	defined in Mozzi/mozzi_config.h, which is 64 unless you change it there.
	You can still define CONTROL_RATE in your sketch and provide it as an argument to startMozzi, as before.
- fixmath.h Added Q8n0_to_Q15n16(Q8n0 a)


Version_0.01.1x

- fixed (I hope) mozzi_config.h being loaded after other things which depend on it,
	which caused multiple definitions of the ISR(ADC_vect).
	Now the analog and audio input sketches should behave as configured.


Version_0.01.1w
Lots of changes which will probably require some search and replace to maintain sketches written with earlier versions:

- mozzi_analog.h, .cpp
	- Renamed startRead() to adcReadAllChannels(), more descriptive of what it does.
	- Renamed getSensor(uint8_t pin) to adcGetResult(uint8_t pin), because the ADC conversions are already done, stored in an array.
	- Renamed adcEnableInterrupt() adcEnableInterrupt().
	- Renamed startAnalogRead(uint8_t pin) to adcStartConversion(uint8_t pin).
	- Renamed adcReceiveAnalogRead() to adcGetResult().
	- Added adcSetChannel() so you can sample from the same pin repeatedly without muxing every time.
	- Added adcDisconnectAllDigitalIns() which helps to reduce analog noise,
	increase  reading speed, and save power by turning off all analog pins' digital input buffers.
	(Just  a loop with disconnectDigitalIn() for each pin).
	- Added adcReconnectAllDigitalIns().
	- Changed adcStartConversion() to use the analog reference voltage set with the main Arduino language.
- Added slightly more sanity to m_32_StateVariable and m_25_LowPassFilter examples.
- MozziGuts.cpp
	- Fixed a bug in the output buffer code which would have been causing frequent inaccuracies in audio output
	- Added an input buffer for audio on analog pin 0.  Audio input can be enabled by putting
	"#define USE_AUDIO_INPUT true" in Mozzi/mozzi_config.h.
	- Added getAudioInput() which works on analog pin 0 if mozzi_config.h contains "#define USE_AUDIO_INPUT true"
		Currently, audio input excludes using other analog inputs, but RC circuits or other interfaces still enable sensor input.
- Added RCpoll.h, a class which wraps the RCtime tutorial from Arduino.cc, for reading voltages from digital pins.
		This is for sensor inputs when using audio input, which currently prevents the use of other analog pins.
- Added example m_39_Audio_Input_with_Filter_Control which demonstrates audio input with RCpoll to control a filter
- Waveshaper.h - fixed some documentation errors.
- Changed names of some of the examples to reflect library changes.
- AudioDelayFeedback - added an alternative next(int8_t in_value, Q16n16 delaytime_cells) function for fractional, linear interpolated delays.
	- Examples for AudioDelayFeedback changed to disambiguate
		next(int8_t in_value, Q16n16 delaytime_cells) and next(int8_t in_value, uint16_t delaytime_cells).
- Moved some documentation into .h files to work around conditional compilation hiding documentation from doxygen.



Version_0.01.1v
- Introduced alternative output options, STANDARD and HIFI.  STANDARD is set by default and is the
	original Mozzi output, 16384Hz, nearly 9 bit PWM on pin 9.
	HIFI is 16384Hz, 14 bits and has a high PWM carrier frequency of 125kHz which
	puts it out of hearing range, addressing an issue where some people have
	problems with a high pitched whine from the original 16kHz carrier frequency.
	HIFI is a big improvement in the sound quality. The cost is that it uses an
	extra timer (Timer2) and uses 2 output pins, 2 resistors and a capacitor to hear
	the output, where STANDARD mode is ready to go without any external parts
	(but can need filters which are more complicated than the HIFI parts).
	For HIFI sketches, you probably want to adjust the output from your
	updateAudio() functions to use the full 14 bits of resolution.
	Check the documentation of the Mozzi core module for hardware set-up and more detail.
- Fixed mtof() so midi note 0 now returns a frequency of 0.
- AudioDelayFeedback() now runs 4.5 times faster, taking 4us instead of 18us per sample.
- LowPassFilter()'s performance is improved from 14us to 10.5us per sample.
- Made LowPassFilter and AudioDelayFeedback examples more sane, with comments.
- Added LowPassFilter_X_2 and AudioDelayFeedback_X_2 examples with 2 each of these
	units running together.
- Renamed fixedMath.h and fixedMath.cpp to mozzi_fixmath.h and mozzi_fixmath.cpp.  Sorry for the inconvenience.
- Renumbered all the examples.  Sorry for the inconvenience.
- Renumbered all the examples.  Sorry for the inconvenience.



Version_0.01.1u
- moved audio Timer 1 ISR to MozziGuts.cpp, so outputAudio() can be inlined, saving about 16ms/s (1.6%, not much!)
- mozzi_utils.h rewrote macros as inline functions, now setPin13Out(), setPin13Low() and setPin13High().  That'll break a few sketches!
- Oscil.h - fixed bug which stopped OSCIL_DITHER_PHASE option finding xorshift96().
- fixed some broken links on the github wiki.
- removed LowPass1stOrder.h - it provided linear interpolation which can be done better with Line().
- removed examples/m_09_LowPass1stOrder


Version_0.01.1t
- Added Portamento.h, in response to ajax on mozzi-users - easier to make a new unit than to do it in a sketch.
- Added example m_34_Teensy_USB_MIDI_portamento.
- Removed MozziTimer2.cpp and MozziTimer2.h, they're not used.  Removed commented references to them in MozziGuts.cpp and MozziGuts.h.
- Removed the commented out references to FrequencyTimer2.cpp and FrequencyTimer2.h in MozziGuts.cpp and MozziGuts.h.
- Online documentation was long out of date, now up to date (I forgot I had to do it manually).  Why can't github follow symlinks?
- Oscil.h - added getPhaseFractional() and setPhaseFractional() for experiments with using addition of out-of-phase oscils to adjust gain instead of using multiplies.
- mozzi_fixmath.h - rewrote #define types as typedefs and conversion macros as inline functions containing static_cast for better compile-time error checking.
- Smooth.h - added a template for floats.  Aah that feels better.


Version_0.01.1s
- Added randSeed() with no parameters, which seeds the random generator with
	noise from reading the Arduino's internal temperature.  This randSeed() leaves analogReference() set to DEFAULT.
	Watch out for that.
- Modified examples m_10_Line_Gliss and m_11_Line_Gliss_Double to be easier to read, with more comments.
- Added experimental compatibility for ATmega644P based boards (gizduino, sanguino), waiting for (anyone?) testers to report.



Version_0.01.1r
- Fixed example m_26_adcGetResult_LowPassFilter, user Doctroid noticed a mistake in the circuit pinout.



Version_0.01.1q
- Added ADSR.h, a simple envelope generator, and an example m_32_ADSR_Envelope.
- Added m_33_Teensy_USB_MIDI_Input example, playing ADSR enveloped notes from a midi source.



Version_0.01.1p

- Moved midi, random and analog input code from utils each into their own files as described below.
	THIS WILL BREAK OLD SKETCHES but is easy to fix by #including the appropriate new *.h files.
- Introduced mozzi_analog.h and mozzi_analog.cpp for new asynchronous analog input functions, much better than the old way.
	- Inserted example m_26_adcGetResult_LowPassFilter to show the new way of reading analog inputs, bumped numbers of
		other examples to make room.
	- Moved old analog stuff to from utils to the new files.
	- Renamed setAnalogInChannel() and unSetAnalogInChannel() to disconnectDigitalIn() and reconnectDigitalIn().  Can't
		tell if disconnectDigitalIn() really makes any difference to analog readings despite the rationale of reducing noise.
- Moved random number generator functions from utils to mozzi_rand.h and mozzi_rand.cpp, adjusted examples.
- Moved midi note-to-frequency conversion functions to mozzi_midi.h and mozzi.midi.cpp.
- Fixed a show-stopping typo in StateVariable.



Version_0.01.1o

- Mega2650 boards should now work properly.  Stephen Scutt identified a bug at upload time,
	if the compiler sees 3 !!! exclamation marks in a row (or 33, 33, 33 in decimal)
	it enters serial mode and the board freezes.  All tables now have occurrences of 33, 33, 33 dithered.
- python/int8_t2mozzi.py, the python script for converting raw data to sound tables now
	changes every 3rd 33 in a row to 32 or 34 (random).
- Examples are renamed, so they are now prefixed with m_##_, eg. m_01_Sinewave, and given a sequential
	numerical order without the "a", "b" etc.  The renaming has to do with a script for a generating web
	page for the code and audio recordings of sketches.
- Ead.h - added function, start(uint16_t attack_ms, uint16_t decay_ms), to set and start a new envelope.
		Changed from switch..case to if..else for checking envelope phase in next().
- Example m_24_Ead_Envelope updated to generate random envelopes, to demonstrate variations.
- Added StateVariable.h, a resonant audio filter with lowpass, bandpass, highpass and notch modes.  This works well.
- m_30_StateVariable_Filter example added.
- removed fastSqrt.h - it's about 25 times slower than avr-lib sqrt()!  Hat tip to the oscilloscope.
- mozzi_utils.h - added setAnalogInChannel(), which disables digital input for a selected analog input pin,
		improving noise and speed.  Also added unSetAnalogInChannel(), to reconnect digital input.


Version_0.01.1n

- EventDelay()
	- IMPORTANT! this will break old sketches.

	  Constructor syntax changed from:

		EventDelay MyEventDelay(UPDATE_RATE);
		to
		EventDelay <UPDATE_RATE> MyEventDelay();

	- added start(uint16_t delay_milliseconds), sets and starts the delay in one go.

- _03c_AMSynth - more detailed, and far more irritating example.
- hack for Teensy 2 (32u4), pasted from hardware/arduino/variants/leonardo/pins_arduino.h (actually included in previous version)
- Sample - fixed bug where phase was incremented even if looping was off and the sample was past the loop point, which caused
	unintentional looping when phase wrapped.
- example _07_Control_Oscil_Wash - modified volume controls to range 0-255 instead of centred around 0, tinkered with frequencies.
- example _08_Detuned_Beats_Wash changed xorshift stuff to rand.
- AudioDelay() - added option to set delaytime_cells in constructor.
- AudioDelayFeedback() - added options to set delaytime_cells and feedback_level in constructor.
- added prime number generator in "primes.h", inspired by Inspired by PrimeSieve by Paul Badger 2009 http://playground.arduino.cc/Main/PrimeSieve
- Line() - fixed some bugs by using ATOMIC_BLOCK and volatile for a variable which could be changed in different interrupts within a sketch.



Version_0.01.1m

- Oscil - fixed inaccurate results for small table sizes in setFreq().
- Removed EventDelay.cpp, EventDelay() is all in the .h file so all inline now.
- Moved all sample tables into "samples" folder, now in top level Mozzi folder.
- Added example _18b_Waveshaper_Difference_Tone.
- Removed examples_recordings folder, each example has its recordings inside in the folder with the example sketch.
- Wrote an automated build and record script to check all examples work for each release.
- Line - fixed a bug which caused incorrect step calculation for unsigned types.
- _03_Control_Tremelo example - added audio-rate linear interpolation to amplitude-control.
- Smooth - increased internal smoothness resolution from Q0n8 to Q0n16 for template parameter types larger than int8_t.
- _05_Smooth example - changed to do smoothing in updateAudio().
- Various examples slightly modified/fixed (more needs doing).


Version_0.01.1l

- fixed randSeed() and xorshift96Seed();
- Sample()
	- added looping parameters
	- changed the internals of next - slower at 4us but more flexible
	- now wave tables can be arbitrary lengths, no more power-of-2 restriction
	- added example _11b_Sample_Loop_Points
- Phasor is now set to output only unsigned longs.  Fixed bad bugs.
- Add example _19_PWM_Phasing, demonstrating Phasor() as an audio generator.


Version_0.01.1k

- Tested and working on Leonardo board.


Version_0.01.1j

- Fixed Phasor and docs.


Version_0.01.1i

- newer version of TimerOne library from http://www.pjrc.com.  Teensy2++ works,
	Arduino Mega and others should also be OK, noting audio out pin differences in README Quick Start section.
- added option for dithering oscillator phase, which can reduce spurious frequencies.  Add it like this:
	#define DITHER_OSCIL_PHASE
	#include <oscil.h>
- added Phasor.h, a high resolution repeating ramp generator, much better for some synth calculations
	than using an 8-bit saw wave oscil.
- lots of typos, etc.


Version_0.01.1h

- more Leonardo/Teensy compatibilty fixes, thanks to massi on mozzi users list.


Version_0.01.1g

- changed control interrupts to Timer0 to test compatibility on atmega32u4 - (Leonardo/Teensy).
	Timer0 is used by Arduino IDE, but Mozzi clobbered it already,
	has EventDelay() to replace delay(), and this now leaves Timer2
	(Timer4 on atmega32u4) free.
- replaced: prog_int8_t with: const int8_t __attribute__((progmem))
	to test compatibility with atmega32u4 (Leonardo/Teeny).
	Changed tables and python scripts to match.
- added example _12c_Samples_Tables_Arrays, showing a way to use
	Samples and sound tables in arrays, and using a small number of Sample players
	to play many sound tables.


Version_0.01.1f

- added WaveShaper(), a table-based waveshaping object suited for audio synthesis,
	with an example sketch,  _18_WaveShaper.
- added tables for use with WaveShaper(), including Chebyshev polynomial curves and sigmoid curves.
- mozzi_utils.h: added rand(), a fast ranged random number generator using xorshift96(),
	for signed and uint8_ts and ints, in rand(min,max) for values
	between min and max-1, and rand(max) for 0 to max-1.
	Much easier to use than xorshift() on its own.
- added a folder of bamboo percussion sample tables - is it possible
	to get clean sounding samples at 8-bit 16384Hz resolution?
	Looking at old Amiga sample archives for hints.
- added _16b_LowPassFilter_AnalogRead_Control example
- lots of typos


Version_0.01.1e

- added LowPass1stOrder.h, an alternative to Smooth which can handle long numbers.
- fixed a bug in Smooth.h which stopped high smoothness values working properly.
- added another example for Smooth, changing freqency.
- fixed errors in mozzi_fixmath.h
- fixed a naming problem in int8_t2mozzi.py
- added _02b_FMsynth example
- added _03b_AMsynth example
- added _05b_Smooth2 example
- added _05c_LowPass1stOrder example


Version_0.01.1d

-mozzi_utils.h: added adcStartConversion() and adcGetResult(), so conversion can
	happen in the background instead of hogging the cpu in Arduino's analogRead().
- mozzi_fixmath.h: tweaks and additions


Version_0.01.1c

- Smooth.h: increased speed from about 400 us to between 1-5 us, depending on
number type, by changing floating to fixed point in internal calculations. Types
are now restricted to int8_t, uint8_t, int16_t and uint16_t.
- mozzi_fixmath.h: changed *_float2fix names to float_to* , added some types and fixed some mistakes
- mozzi_utils.h:
	-hardcoded midiToFreq[] array to progmem instead of generating on startup
	-removed old Q16n16_mtof() and renamed Q16n16_mtofLookup() to Q16n16_mtof().
	The old Q16n16_mtof() was slower and less accurate than the lookup version.
- fixed example _08_Detuned_Beats_Wash to work with new midi, fixed-point and Oscil setFreq_Q16n16 code.


Version_0.01.1b

- Oscil.h:
	- added a setPhase() method to play a table from any position.
	- added setFreq_Q16n16() for setting frequency using Q16n16 fixed-point numbers
- _09_PhaseMod_Envelope example wasn't showing up in Arduino, fixed the name so it can be found.
- added triangle, saw and cos tables in sizes 256, 512, 1024, 2048, 4096 and 8192
- added a float2mozzi_uint8.py, renamed the other wave converter scripts and made them more uniform
- mozzi_utils.h/utils.cpp:
	- added Q16n16_mtofLookup(), a fast (but less accurate for non-integer midi note numbers) fixed point alternative to mtof().
	- added Q16n16_mtof(), a faster (but less accurate overall) fixed point alternative to mtof().
	- changed setupFastADC() to setupFastAnalogRead()
- replaced TABLE_NUM_CELLS with NUM_CELLS in tables


Version_0.01.1

- Changed utils.c to utils.cpp and changed all examples from #include utils.c to #include mozzi_utils.h.
- Changed and capitalised names in saw_analogue512_int8.h
- Removed some wavetables which were too short. (should make more 1024 & 2048 tables)
- Oscil.h and Sample.h, added a constructor for declaring without a table, and a setTable() method, prompted by "konsumer' on mozzi-users
