Gugen展示版
Fork of MagneWave by
Diff: MagneWave.cpp
- Revision:
- 2:0fc5df933021
- Parent:
- 1:a82b9af36dbf
- Child:
- 3:500b992880b3
diff -r a82b9af36dbf -r 0fc5df933021 MagneWave.cpp --- a/MagneWave.cpp Tue Oct 29 15:58:06 2013 +0000 +++ b/MagneWave.cpp Thu Oct 31 15:07:37 2013 +0000 @@ -1,9 +1,12 @@ #include "MagneWave.h" +#define DATA_OFFSET 44 +#define DAC_CENTER 32768 + MagneWave::MagneWave( SoftMCP4922 *dac ) { m_wave_DAC = dac; - m_wave_DAC->write_u16( 32768 ); + m_wave_DAC->write_u16( DAC_CENTER ); } void MagneWave::play( FILE *wavefile ) @@ -16,11 +19,11 @@ dataSize |= ( fgetc( wavefile ) << 8 ); dataSize |= ( fgetc( wavefile ) << 16 ); dataSize |= ( fgetc( wavefile ) << 24 ); - printf("data size = %ld\n", dataSize ); + printf( "data size = %ld\n", dataSize ); #endif // jump to wave data - fseek( wavefile, 44, SEEK_SET ); + fseek( wavefile, DATA_OFFSET, SEEK_SET ); while(1){ //16bit @@ -50,6 +53,6 @@ m_wave_DAC->write_u8( ( unsigned short )dacVal8 ); // TODO: adjust cycle - wait_us(100); + wait_us( 75 ); } }