25 #include "soundheader.h"
33 void streamThisChannel(
int source,
int bytesToStream,
int offset) {
35 int readSizeThrowAway;
40 wavfile = sndfile[source];
49 if (wavfile->bytes_remaining == UNINITWAV) {
51 rewind_to_beginning(wavfile);
54 if (wavfile->bytes_remaining <= 0) {
56 if (loop[source] == 1) {
57 rewind_to_beginning(wavfile);
75 if (wavfile->bytes_remaining < bytesToStream) {
76 readSize = (int) (wavfile->bytes_remaining);
77 wavfile->bytes_remaining = 0;
79 readSize = bytesToStream;
80 wavfile->bytes_remaining = wavfile->bytes_remaining -
81 (
long int) bytesToStream;
88 readSizeThrowAway = fread(wavfile->data,readSize,1,wavfile->fd);
89 addToCombiningBuffer(source,readSize,offset);
93 if (readSize < bytesToStream) {
94 streamThisChannel(source, bytesToStream-readSize,
101 void streamMoreData(
int bytesToStream) {
103 int writeSizeThrowAway;
105 if (bytesToStream > MAXBUFSIZE) {bytesToStream = MAXBUFSIZE;
109 for (count = 0; count <= current_max; count++) {
110 if ((active[count] == 1 ) && (registered[count] == 1)) {
112 if ((sndfile[count]->ampl) > 0) {
113 streamThisChannel(count,bytesToStream,0);
120 if (sndfile[count]!=NULL) {
121 sndfile[count]->ampl = (sndfile[count]->ampl) - 5;
122 if ((sndfile[count]->ampl) <= 0) {
123 sndfile[count]->ampl = 0;
129 writeSizeThrowAway = write (dspFile, CombiningBuffer, bytesToStream);