Wave format audio file sampling rate conversion
First, this conversion method is a file conversion method, and a new audio file is generated on the basis of the current file analysis.
Second, the method takes more time, but the speed is within the allowable range
Third, the analysis document is in one byte operation when writing new files
4. The new file generated by this method is only 16 bits. If other precision is required, it is necessary to perform precision conversion.
Operating procedures:
First, the head structure of the source file, the sampling rate, the number of channels, data length, and data traffic of the source file is obtained.
2. According to the file head structure, the head structure of the new file is generated, and each parameter is determined, where the sampling rate is specified by the user.
Third, determine the number of cycles of the conversion based on the sampling rate of the source file and the number of channels.
Fourth, acquire and transform the voice data of the source file, the conversion formula:
(((ITMP << 8) ITMP) -32768) << 16
Among them, ITMP is a double-byte data acquired.
5. Transfer the converted data to the file you need to write, and turn again, the formula is as follows:
1, c = (((C 0x80000000) >> 16) & 0xfff) ^ 0x8000;
Where C is incoming sampling rate data
The data that needs to be converted to bytes are required, and the formula is as follows:
First byte C & 0xFF
Second byte c >> 8
Write the first byte with the second byte to the newly generated file.
6. The source file is looped with the target file, only the end of the source file.