• Home
  • Raw
  • Download

Lines Matching refs:file

30     waveFile file,  in writeBytes()  argument
36 if(file->failed) { in writeBytes()
39 bytesWritten = fwrite(bytes, sizeof(char), length, file->soundFile); in writeBytes()
42 file->failed = 1; in writeBytes()
44 file->bytesWritten += bytesWritten; in writeBytes()
49 waveFile file, in writeString() argument
52 writeBytes(file, string, strlen(string)); in writeString()
57 waveFile file, in writeInt() argument
67 writeBytes(file, bytes, 4); in writeInt()
72 waveFile file, in writeShort() argument
82 writeBytes(file, bytes, 2); in writeShort()
87 waveFile file, in readBytes() argument
91 if(file->failed) { in readBytes()
94 return fread(bytes, sizeof(char), length, file->soundFile); in readBytes()
99 waveFile file, in readExactBytes() argument
105 if(file->failed) { in readExactBytes()
108 numRead = fread(bytes, sizeof(char), length, file->soundFile); in readExactBytes()
111 file->failed = 1; in readExactBytes()
117 waveFile file) in readInt() argument
122 readExactBytes(file, bytes, 4); in readInt()
132 waveFile file) in readShort() argument
137 readExactBytes(file, bytes, 2); in readShort()
147 waveFile file, in expectString() argument
155 file->failed = 1; in expectString()
157 readExactBytes(file, buf, length); in expectString()
161 file->failed = 1; in expectString()
168 waveFile file, in writeHeader() argument
172 writeString(file, "RIFF"); /* 00 - RIFF */ in writeHeader()
175 writeInt(file, 36 /* + dataLength */); /* 04 - how big is the rest of this file? */ in writeHeader()
176 writeString(file, "WAVE"); /* 08 - WAVE */ in writeHeader()
177 writeString(file, "fmt "); /* 12 - fmt */ in writeHeader()
178 writeInt(file, 16); /* 16 - size of this chunk */ in writeHeader()
179 writeShort(file, 1); /* 20 - what is the audio format? 1 for PCM = Pulse Code Modulation */ in writeHeader()
180 writeShort(file, 1); /* 22 - mono or stereo? 1 or 2? (or 5 or ???) */ in writeHeader()
181 writeInt(file, sampleRate); /* 24 - samples per second (numbers per second) */ in writeHeader()
182 writeInt(file, sampleRate * 2); /* 28 - bytes per second */ in writeHeader()
183 writeShort(file, 2); /* 32 - # of bytes in one sample, for all channels */ in writeHeader()
184 writeShort(file, 16); /* 34 - how many bits in a sample(number)? usually 16 or 24 */ in writeHeader()
185 writeString(file, "data"); /* 36 - data */ in writeHeader()
186 writeInt(file, 0); /* 40 - how big is this data chunk */ in writeHeader()
191 waveFile file) in readHeader() argument
195 expectString(file, "RIFF"); in readHeader()
196 data = readInt(file); /* 04 - how big is the rest of this file? */ in readHeader()
197 expectString(file, "WAVE"); /* 08 - WAVE */ in readHeader()
198 expectString(file, "fmt "); /* 12 - fmt */ in readHeader()
199 int chunkSize = readInt(file); /* 16 or 18 - size of this chunk */ in readHeader()
204 data = readShort(file); /* 20 - what is the audio format? 1 for PCM = Pulse Code Modulation */ in readHeader()
209 file->numChannels = readShort(file); /* 22 - mono or stereo? 1 or 2? (or 5 or ???) */ in readHeader()
210 file->sampleRate = readInt(file); /* 24 - samples per second (numbers per second) */ in readHeader()
211 readInt(file); /* 28 - bytes per second */ in readHeader()
212 readShort(file); /* 32 - # of bytes in one sample, for all channels */ in readHeader()
213 data = readShort(file); /* 34 - how many bits in a sample(number)? usually 16 or 24 */ in readHeader()
219 data = readShort(file); in readHeader()
221 expectString(file, "data"); /* 36 - data */ in readHeader()
222 readInt(file); /* 40 - how big is this data chunk */ in readHeader()
228 waveFile file) in closeFile() argument
230 FILE *soundFile = file->soundFile; in closeFile()
234 file->soundFile = NULL; in closeFile()
236 free(file); in closeFile()
245 waveFile file; in openInputWaveFile() local
252 file = (waveFile)calloc(1, sizeof(struct waveFileStruct)); in openInputWaveFile()
253 file->soundFile = soundFile; in openInputWaveFile()
254 file->isInput = 1; in openInputWaveFile()
255 if(!readHeader(file)) { in openInputWaveFile()
256 closeFile(file); in openInputWaveFile()
259 *sampleRate = file->sampleRate; in openInputWaveFile()
260 *numChannels = file->numChannels; in openInputWaveFile()
261 return file; in openInputWaveFile()
270 waveFile file; in openOutputWaveFile() local
277 file = (waveFile)calloc(1, sizeof(struct waveFileStruct)); in openOutputWaveFile()
278 file->soundFile = soundFile; in openOutputWaveFile()
279 file->sampleRate = sampleRate; in openOutputWaveFile()
280 file->numChannels = numChannels; in openOutputWaveFile()
281 writeHeader(file, sampleRate); in openOutputWaveFile()
282 if(file->failed) { in openOutputWaveFile()
283 closeFile(file); in openOutputWaveFile()
286 return file; in openOutputWaveFile()
291 waveFile file) in closeWaveFile() argument
293 FILE *soundFile = file->soundFile; in closeWaveFile()
296 if(!file->isInput) { in closeWaveFile()
302 writeInt(file, file->bytesWritten - 8); in closeWaveFile()
303 if(file->failed) { in closeWaveFile()
312 writeInt(file, file->bytesWritten - 48); in closeWaveFile()
313 if(file->failed) { in closeWaveFile()
320 closeFile(file); in closeWaveFile()
326 waveFile file, in readFromWaveFile() argument
335 if(maxSamples*file->numChannels*2 > WAVE_BUF_LEN) { in readFromWaveFile()
336 maxSamples = WAVE_BUF_LEN/(file->numChannels*2); in readFromWaveFile()
338 bytesRead = readBytes(file, bytes, maxSamples*file->numChannels*2); in readFromWaveFile()
339 samplesRead = bytesRead/(file->numChannels*2); in readFromWaveFile()
340 for(i = 0; i < samplesRead*file->numChannels; i++) { in readFromWaveFile()
350 waveFile file, in writeToWaveFile() argument
358 int total = numSamples*file->numChannels; in writeToWaveFile()
362 writeBytes(file, bytes, bytePos); in writeToWaveFile()
370 writeBytes(file, bytes, bytePos); in writeToWaveFile()
372 return file->failed; in writeToWaveFile()