Gugen展示版
Fork of MagneWave by
MagneWave.cpp
- Committer:
- doctorura
- Date:
- 2013-10-29
- Revision:
- 0:5a700113dd87
- Child:
- 1:a82b9af36dbf
File content as of revision 0:5a700113dd87:
#include "MagneWave.h" MagneWave::MagneWave( SoftMCP4922 *dac ) { m_wave_DAC = dac; m_wave_DAC->write_u16( 32768 ); } void MagneWave::play( FILE *wavefile ) { #if 0 // data size check unsiged long dataSize = 0; seek( wavefile, 40, SEEK_SET ); dataSize = fgetc( wavefile ); dataSize |= ( fgetc( wavefile ) << 8 ); dataSize |= ( fgetc( wavefile ) << 16 ); dataSize |= ( fgetc( wavefile ) << 24 ); printf("data size = %ld\n", dataSize ); #endif // jump to wave data fseek( wavefile, 44, SEEK_SET ); while(1){ int tmpL = 0; int tmpH = 0; unsigned short dacVal16 = 0; tmpL = fgetc( wavefile ); if( tmpL == EOF ){ break; } tmpH = fgetc( wavefile ); if( tmpH == EOF ){ break; } dacVal16 = tmpL; dacVal16 |= ( tmpH << 8 ); m_wave_DAC->write_u16( dacVal16 ); // TODO: adjust cycle wait( 0.005 ); } }