EZ-Additive Synthesizer By Max Bastien 12/14/07. Problem Statement Mystery of keyboards reproducing...

Preview:

Citation preview

EZ-Additive Synthesizer

By Max Bastien12/14/07

Problem Statement Mystery of keyboards reproducing a wide range of

sounds from any particular instrument with just one digital sample played or none at all.

What is a Synthesizer?

A synthesizer is an electronic musical instrument

Creates sounds by manipulating an analog signal using various

techniques.

Various Techniques

Additive SynthesisSubtractive Synthesis

FM SynthesisWavetable Synthesis

Additive Technique Additive Synthesis is the process of

summing such sinusoids to produce a wide variety of composite signals.

An input signal is modified by however many functions with a variable Amplitude, Frequency and Phase values then the resultant signal is multiplied by the summation.

NNN nfAnfAnfAny 2sin2sin2sin 222111

Key Aspects

Frequency Amplitude

Phase

SpecificationsMain Output Switch – PF8Pressed once – all outputs and Led4 are inactive (this is the default case at start-up) Pressed for a second time - all outputs and Led4 are activePressed for a 3rd time – resets back to case state of pressed once

Additive Synthesis Toggle – PF9Pressed once – Synthesis function and Led5 are inactive (default case)Pressed twice - Synthesis function and Led5 are active Pressed for a third time – reset back to case state of pressed once

Volume Increment Toggle – PF10 Default case – Volume is set to 0 (mute)Pressed once to ten times – volume increments by 10 Pressed for an eleventh time – reset back to default case

Frequency Increment Toggle – PF10 Default case – All frequency set to 200Pressed once to ten times – frequencies increments by 100 Pressed for an eleventh time – reset back to default case

Essential Code Fragmentsvoid AddSynth(float a1, float a2, float a3,float a4,int f1,int f2,int f3,int f4)

{int substitute = iChannel0LeftIn << 8;

static int x = 0;

float fi1 = pi/3;float fi2 = pi/3;float fi3 = pi/3;float fi4 = pi/3; float sine1 = a1*sinf(2*pi*f1*x+fi1);float sine2 = a2*sinf(2*pi*f2*x+fi2);float sine3 = a3*sinf(2*pi*f3*x+fi3);float sine4 = a4*sinf(2*pi*f4*x+fi4);

float synoutput = substitute * (sine1 + sine2 + sine3 + sine4);

//increment sample sizex++;

if(x >= 150)x = 0;

iChannel0LeftIn = synoutput;iChannel0RightIn = synoutput;

//outputing soundiChannel0LeftIn = iChannel0LeftIn >> 8;iChannel0RightIn = iChannel0RightIn >> 8;

}

NNN nfAnfAnfAny 2sin2sin2sin 222111

EX_INTERRUPT_HANDLER(Sport0_RX_ISR)

{

// confirm interrupt handling*pDMA1_IRQ_STATUS = 0x0001;

////////PF8 deafult case if (Counter1==0){

//Turn all Leds OFF - no output but8=0x00;

}

//If button is toggled all output and Led4 activeif (Counter1==1){

// copy processed data from variables into dma output bufferiTxBuffer1[INTERNAL_DAC_L0] = iChannel0LeftOut;iTxBuffer1[INTERNAL_DAC_R0] = iChannel0RightOut;

//Turn LED4 ONbut8=0x01;

}

Interrupt Handler

Cont’d////////PF9 default case

if (Counter2==0){

//turn Led5 offbut9=0x00;

}

if (Counter2==1){

//Make channel 0 activeiChannel0LeftIn = iRxBuffer1[INTERNAL_ADC_L0];iChannel0RightIn = iRxBuffer1[INTERNAL_ADC_R0 ];

//Turn Led5 ONbut9=0x02;

//Call function for sound productionAddSynth(a1, a2, a3, a4, f1, f2, f3, f4);

//Make output active iChannel0LeftOut = iChannel0LeftIn;

iChannel0RightOut = iChannel0RightIn;

}

*pFlashA_PortB_Data = but8|but9|but10;}

FlagsEX_INTERRUPT_HANDLER(FlagA_ISR){

if (*pFIO_FLAG_C == 0x0100) //Checks PF8{

// confirm interrupt handling*pFIO_FLAG_C = 0x0100;

//Increment CountCounter1++;if(Counter1==2)Counter1=0;

}

else if (*pFIO_FLAG_C == 0x0200) //Checks PF9{

// confirm interrupt handling*pFIO_FLAG_C = 0x0200; Counter2++;if(Counter2==2)Counter2=0;

}

else if (*pFIO_FLAG_C == 0x0400) //Checks PF10{

*pFIO_FLAG_C = 0x0400;

a1, a2, a3, a4 += 10; if (a1, a2, a3, a4 >= 100)

a1, a2, a3, a4 = 0; }

else if (*pFIO_FLAG_C == 0x0800) //Checks PF11{

*pFIO_FLAG_C = 0x0800;

f1, f2, f3, f4 +=100; if (f1, f2, f3, f4 >= 1300) f1, f2, f3, f4 = 200; }

Results

Project = success running w/o errors

Practical UsesSpecial effects

Replication of instrumentsSounds cards

Recommended