参考WAV格式,更改结构值看:24 // 定义win32中的 WAVEFORMATEX 25 #ifndef _WAVEFORMATEX_ 26 #define _WAVEFORMATEX_ 27 28 /* 29 * extended waveform format structure used for all non-PCM formats. this 30 * structure is common to all non-PCM formats. 31 */ 32 typedef struct tWAVEFORMATEX 33 { 34 WORD wFormatTag; /* format type */ 35 WORD nChannels; /* number of channels (i.e. mono, stereo) */ 36 DWORD nSamplesPerSec; /* sample rate */ 37 DWORD nAvgBytesPerSec; /* for buffer estimation */ 38 WORD nBlockAlign; /* block size of data */ 39 WORD wBitsPerSample; /* number of bits per sample of mono data */ 40 WORD cbSize; /* the count in bytes of the size of */ 41 /* extra information (after cbSize) */ 42 } WAVEFORMATEX, *PWAVEFORMATEX, NEAR *NPWAVEFORMATEX, FAR *LPWAVEFORMATEX; 43 44 #endif /* _WAVEFORMATEX_ */ 45 46 ////////////////////////////////////////////////////////////////////////// 47 // 定义format chunk 信息 48 typedef struct _formatchunk 49 { 50 char chunkId[4]; // "fmt" 51 DWORD chunkSize; // numbers of bits of this chunk, not including chunkId and chunkSize 52 53 WORD wFormatTag; // Format category, 对于未压缩的WAV,取值为WAVE_FORMAT_PCM 0x0001 54 WORD wChannels; // Number of channels 55 DWORD dwSamplesPerSec; // Sampling rate 56 DWORD dwAvgBytesPerSec; // For buffer estimation 57 WORD wBlockAlign; // Data block size, or say the size of the sample frame, equals 58 // wBlockAlign = (wBitsPerSample % 8) * wChannels 59 WORD wBitsPerSample; // Sample size, wFormatTag is PCM 60 WORD wReserved; // Reserved Field; 61 62 } FormatChunk, *LPFormatChunk; 或现成的播放器,如media player等,就有调节播放速度的插件,当然,如果需要自己写代码,使用ds的SetRate也是可以实现的,ds的SetRate音频(3分钟)就可以慢速播放 MediaPlayer mp = new MediaPlayer(); mp.SpeedRatio = 0.3; mp.Open(new Uri(@"C:\Windows\Media\ringout.wav")); mp.Play();
25 #ifndef _WAVEFORMATEX_
26 #define _WAVEFORMATEX_
27
28 /*
29 * extended waveform format structure used for all non-PCM formats. this
30 * structure is common to all non-PCM formats.
31 */
32 typedef struct tWAVEFORMATEX
33 {
34 WORD wFormatTag; /* format type */
35 WORD nChannels; /* number of channels (i.e. mono, stereo) */
36 DWORD nSamplesPerSec; /* sample rate */
37 DWORD nAvgBytesPerSec; /* for buffer estimation */
38 WORD nBlockAlign; /* block size of data */
39 WORD wBitsPerSample; /* number of bits per sample of mono data */
40 WORD cbSize; /* the count in bytes of the size of */
41 /* extra information (after cbSize) */
42 } WAVEFORMATEX, *PWAVEFORMATEX, NEAR *NPWAVEFORMATEX, FAR *LPWAVEFORMATEX;
43
44 #endif /* _WAVEFORMATEX_ */
45
46 //////////////////////////////////////////////////////////////////////////
47 // 定义format chunk 信息
48 typedef struct _formatchunk
49 {
50 char chunkId[4]; // "fmt"
51 DWORD chunkSize; // numbers of bits of this chunk, not including chunkId and chunkSize
52
53 WORD wFormatTag; // Format category, 对于未压缩的WAV,取值为WAVE_FORMAT_PCM 0x0001
54 WORD wChannels; // Number of channels
55 DWORD dwSamplesPerSec; // Sampling rate
56 DWORD dwAvgBytesPerSec; // For buffer estimation
57 WORD wBlockAlign; // Data block size, or say the size of the sample frame, equals
58 // wBlockAlign = (wBitsPerSample % 8) * wChannels
59 WORD wBitsPerSample; // Sample size, wFormatTag is PCM
60 WORD wReserved; // Reserved Field;
61
62 } FormatChunk, *LPFormatChunk;
或现成的播放器,如media player等,就有调节播放速度的插件,当然,如果需要自己写代码,使用ds的SetRate也是可以实现的,ds的SetRate音频(3分钟)就可以慢速播放
MediaPlayer mp = new MediaPlayer();
mp.SpeedRatio = 0.3;
mp.Open(new Uri(@"C:\Windows\Media\ringout.wav"));
mp.Play();