Part of MicroGen4 Music Synthesizer Program. (But not test it yet.) I2S ,DMA ,Stereo ,16Bit Dac(PCM1781) See detail: http://www.geocities.jp/micro_diys/index2

Dependencies:   mbed

Now added generate Saw Wave to DAC function in generate(); You will hear Stereo saw wave sound now. /media/uploads/p_igmon/i2s_sample_test_audacity.png

more info: http://www.geocities.jp/micro_diys/i2s_test_sample/i2s_test_sample.html

Synthesizer.cpp

Committer:
p_igmon
Date:
2014-07-03
Revision:
0:dc88722ab141
Child:
1:48f506a7b488

File content as of revision 0:dc88722ab141:

/*
    COPYRIGHT(c) 2014 p.igmon
*/

#include "synthesizer.h"

/* DMA WAVE BUFFER */
extern S16 DMA_Buffer[];
extern __IO BUFFER_StateTypeDef BufferOffset;

void wave_generate(void){
    U16 count;
    S16 rch,lch;// 16bit stereo
    volatile S16 *ptr0;

    if (BufferOffset == DMA_FullComplete){
        ptr0 = (S16 *)&DMA_Buffer[DMA_BUFFERSIZE>>1];// From Half
    }else{
        ptr0 = (S16 *)&DMA_Buffer[0];// From Top
    }    
    BufferOffset = DMA_Idle;

    count = DMA_BUFFERSIZE/4;
    while(count-- > 0){

        /* generate wave here */
//      lch = .....
//      rch = .....
        *ptr0++ = lch;
        *ptr0++ = rch;
     }
}