Music notes
From Wikiid
Miscellaneous notes about computer music
Ode To Joy
This is a handy quicky test:
int odeToJoy[] = { F2S,QUARTER, F2S,QUARTER, G2 ,QUARTER, A3 ,QUARTER, A3 ,QUARTER, G2 ,QUARTER, F2S,QUARTER, E2 ,QUARTER, D2 ,QUARTER, D2 ,QUARTER, E2 ,QUARTER, F2S,QUARTER, F2S,DOTTED_QUARTER, E2,EIGHTH, E2,HALF, F2S,QUARTER, F2S,QUARTER, G2 ,QUARTER, A3 ,QUARTER, A3 ,QUARTER, G2 ,QUARTER, F2S,QUARTER, E2 ,QUARTER, D2 ,QUARTER, D2 ,QUARTER, E2 ,QUARTER, F2S,QUARTER, E2 ,DOTTED_QUARTER, D2,EIGHTH, D2,HALF, E2 ,QUARTER, E2 ,QUARTER, F2S,QUARTER, D2 ,QUARTER, E2 ,QUARTER, F2S,EIGHTH, G2,EIGHTH, F2S,QUARTER, D2 ,QUARTER, E2 ,QUARTER, F2S,EIGHTH, G2,EIGHTH, F2S,QUARTER, E2 ,QUARTER, D2 ,QUARTER, E2 ,QUARTER, A,QUARTER, REST,ETERNITY } ;
Digital filter
filter ( input, tunefactor, damping ) { lowpass += tunefactor * bandpass ; highpass = input - lowwpass - damping * bandpass ; bandpass += tunefactor * highpass ; notch = lowpass + highpass ; // Optional! }
Another Low-pass filter
Calculate each output-signal sample as the sum of the input signal and the previous output signal with scaling. This defines a low pass single-pole filter:
Yn = Xn.(1-T) + Yn-1.T
Where:
- Xn is the input
- Yn is the output, Yn–1 is the output from the previous loop.
- T is our frequency control: 0<T<1
Physically, T is the amount of decay between adjacent output samples for a 'step' input. You can directly specify the value of T or derive it from the time constant of the filter, d, which is the number of samples it takes the output to rise to 63.2% of the steady-state level for a lowpass filter. T=e–1/d.
Instead of multiplying by 1–T, it is more convenient to divide by the F=1/(1–T):
Yn = Yn–1 + (Xn–Yn–1)/F
You can determine the digital filter’s parameters using the following steps:
- Choose a value for F. Suppose F==8, so you can do a right-shift instead of a divide.
- Calculate T = 1–1/F = 1–1/8 = 0.875.
- Calculate the time constant as d = –1/ln(T) = –1/ln(0.875) = 7.49 samples.
- Multiply that into your sample rate: 22000/7.49 = 2.9kHz
Wikiid Pages relating to Arduino (edit) |
Arduino |
Command line Arduino |
Startup code for Arduino |
Low level functions for Arduino |
Putting data in flash on the Arduino |
External resources for Arduino |
Board schematics for Arduino |
Misc notes: Circuit notes, Music notes, Stepper motors |