Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed USBDevice PinDetect
Audio/KarplusStrong.h
- Committer:
- asuszek
- Date:
- 2016-04-17
- Revision:
- 13:bb0ec927e458
- Child:
- 15:aa5a4c350251
File content as of revision 13:bb0ec927e458:
/** * The processor used for teh implementation of Karplus strong. * * @author Austin Suszek */ #ifndef AS_KARPLUS_STRONG_H #define AS_KARPLUS_STRONG_H #include <math.h> #include <stdlib.h> #include <time.h> #include "../Constants.h" class KarplusStrong { public: /** * Constructor */ KarplusStrong(); /** * Signal the start of a new note. * * @param key The integer representation of the note * @param velocity The float representation of the velocity (NOT int!) */ void midiNoteOn(int key, float velocity); /** * Create the initial buffer sample for the specific index. * * @param bufferIndex The index to process * @return The new sample to save in the buffer */ float fillBuffer(const int bufferIndex); /** * Process the existing buffer for the specific index. * * @param inputSample The sample to process from the buffer * @return The modified sample to save in the buffer */ float processBuffer(const float inputSample); private: static void initializeNoiseSeed(); static float getRand() { return float(rand()) / float(RAND_MAX); }; float lastOutput; float filterCoefficient; float nextFilterCoefficient; float velocity; float lowpassFilter(const float output, const float input, const float smoothingFactor); }; #endif