Source file: /~heha/basteln/Haus/Telefon/Sprachausgabe.zip/VS6/pwm.cpp

#include "i2s.h"
#include <stdio.h>
#ifdef WIN32
# include <windows.h>
static DWORD*buffer;
static BYTE*fill;

void i2s_begin() {
 buffer=new DWORD[16*1024];	// 64 KByte
 buffer[0]='FFIR';	// RIFF
 buffer[2]='EVAW';	// WAVE
 buffer[3]=' tmf';	// fmt
 buffer[4]=4*4;
 buffer[5]=MAKELONG(1/*PCM*/,1/*channels*/);
 buffer[8]=MAKELONG(1/*channels*bits>>3*/,8/*bits*/);
 buffer[9]='atad';	// data
 fill=(BYTE*)(buffer+11);
}
void i2s_set_rate(unsigned saps) {
 buffer[7]=buffer[6]=saps;
}
extern "C" void i2s_write_sample_b(unsigned char sa) {
 *fill++=sa;
}
void i2s_end() {
 DWORD len=fill-(BYTE*)buffer;	// Anzahl Bytes
 buffer[1]=len-=2*sizeof(DWORD);	// Chunk-Längen eintragen
 buffer[10]=len-=9*sizeof(DWORD);
#ifdef _DEBUG
 printf("%u samples\n",len);
#endif
 sndPlaySound((PCSTR)buffer,SND_MEMORY|SND_SYNC);
 delete[] buffer;
}
#else
# include <avr/io.h>
static unsigned len;

void i2s_begin() {len=0;}

void i2s_set_rate(unsigned) {
 TCCR1B=1;
}
extern "C" void i2s_write_sample_b(unsigned char sa) {
 OCR1B=sa;
}
void i2s_end() {
 TCCR1B=0;
#ifdef _DEBUG
 printf("%u samples\n",len);
#endif
}
#endif
Detected encoding: ANSI (CP1252)4
Wrong umlauts? - Assume file is ANSI (CP1252) encoded