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
Now added generate Saw Wave to DAC function in generate(); You will hear Stereo saw wave sound now.
more info: http://www.geocities.jp/micro_diys/i2s_test_sample/i2s_test_sample.html
Synthesizer.cpp@0:dc88722ab141, 2014-07-03 (annotated)
- Committer:
- p_igmon
- Date:
- Thu Jul 03 11:59:07 2014 +0000
- Revision:
- 0:dc88722ab141
- Child:
- 1:48f506a7b488
Part of MicroGen4 Music Syntesizer program.
; I2S DMA Stereo DAC (PCM1781)
; http://www.geocities.jp/micro_diys/index2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
p_igmon | 0:dc88722ab141 | 1 | /* |
p_igmon | 0:dc88722ab141 | 2 | COPYRIGHT(c) 2014 p.igmon |
p_igmon | 0:dc88722ab141 | 3 | */ |
p_igmon | 0:dc88722ab141 | 4 | |
p_igmon | 0:dc88722ab141 | 5 | #include "synthesizer.h" |
p_igmon | 0:dc88722ab141 | 6 | |
p_igmon | 0:dc88722ab141 | 7 | /* DMA WAVE BUFFER */ |
p_igmon | 0:dc88722ab141 | 8 | extern S16 DMA_Buffer[]; |
p_igmon | 0:dc88722ab141 | 9 | extern __IO BUFFER_StateTypeDef BufferOffset; |
p_igmon | 0:dc88722ab141 | 10 | |
p_igmon | 0:dc88722ab141 | 11 | void wave_generate(void){ |
p_igmon | 0:dc88722ab141 | 12 | U16 count; |
p_igmon | 0:dc88722ab141 | 13 | S16 rch,lch;// 16bit stereo |
p_igmon | 0:dc88722ab141 | 14 | volatile S16 *ptr0; |
p_igmon | 0:dc88722ab141 | 15 | |
p_igmon | 0:dc88722ab141 | 16 | if (BufferOffset == DMA_FullComplete){ |
p_igmon | 0:dc88722ab141 | 17 | ptr0 = (S16 *)&DMA_Buffer[DMA_BUFFERSIZE>>1];// From Half |
p_igmon | 0:dc88722ab141 | 18 | }else{ |
p_igmon | 0:dc88722ab141 | 19 | ptr0 = (S16 *)&DMA_Buffer[0];// From Top |
p_igmon | 0:dc88722ab141 | 20 | } |
p_igmon | 0:dc88722ab141 | 21 | BufferOffset = DMA_Idle; |
p_igmon | 0:dc88722ab141 | 22 | |
p_igmon | 0:dc88722ab141 | 23 | count = DMA_BUFFERSIZE/4; |
p_igmon | 0:dc88722ab141 | 24 | while(count-- > 0){ |
p_igmon | 0:dc88722ab141 | 25 | |
p_igmon | 0:dc88722ab141 | 26 | /* generate wave here */ |
p_igmon | 0:dc88722ab141 | 27 | // lch = ..... |
p_igmon | 0:dc88722ab141 | 28 | // rch = ..... |
p_igmon | 0:dc88722ab141 | 29 | *ptr0++ = lch; |
p_igmon | 0:dc88722ab141 | 30 | *ptr0++ = rch; |
p_igmon | 0:dc88722ab141 | 31 | } |
p_igmon | 0:dc88722ab141 | 32 | } |