wav

How to play non-PCM file or convert it to PCM on the fly ?

Deadly 提交于 2020-01-11 09:32:24
问题 The following code works with some wav files, but with others I get, "InvalidOperationException was unhandled. Message=Sound API only supports playing PCM wave files." var webClient = new WebClient(); webClient.DownloadFile(url, fileName); var fileSound = new SoundPlayer(fileName); fileSound.PlaySync(); Is there a way to programmatically check if a wav file is "bad" (not a PCM wave file) and then convert it as necessary? What is odd is that the code works in the legacy Delphi app - all of the

How to play non-PCM file or convert it to PCM on the fly ?

早过忘川 提交于 2020-01-11 09:32:14
问题 The following code works with some wav files, but with others I get, "InvalidOperationException was unhandled. Message=Sound API only supports playing PCM wave files." var webClient = new WebClient(); webClient.DownloadFile(url, fileName); var fileSound = new SoundPlayer(fileName); fileSound.PlaySync(); Is there a way to programmatically check if a wav file is "bad" (not a PCM wave file) and then convert it as necessary? What is odd is that the code works in the legacy Delphi app - all of the

Convert 3-byte stereo WAV-file to numpy array

☆樱花仙子☆ 提交于 2020-01-11 05:31:05
问题 I have been given a large WAV-file of continuous underwater recording which I would like to convert to a numpy array for analysis. I am struggling to do this. So far I have: import numpy as np import scipy as sp import wave as wv import struct wavefile = wv.open(filename,'r') (nchannels,sampwidth,framerate,nframes,comptype,compname) = wavefile.getparams() // read a sample as example wavedata =wavefile.readframes(1) The first frame looks like this: '\xcd\xbc\xff@\x01\x00'. I have tried to

Playing .mp3 files with PyAudio

僤鯓⒐⒋嵵緔 提交于 2020-01-10 20:01:22
问题 Can pyaudio play .mp3 files? If yes, may I ask to write an example please. If no, what is the simplest way to convert .mp3 to .wav? I have tried to use PyDub, could get my .wav file, but when I try to play it with PyAudio I get following error: File "C:\Python33\lib\wave.py", line 130, in initfp raise Error('file does not start with RIFF id') wave.Error: file does not start with RIFF id With other .wav samples (which where not converted from mp3) if works well. I am using gTTS library to

adding echo effect to a .wav file

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-07 09:40:41
问题 I have written the following code in c++ (sample code) to modify the data present in the original .wav file and write the modified data to a newly created file. This program gives 'echo-effect' to the sound (note:- this is written for a wav file with just 2 channels). #include <iostream> #include <conio.h> #include <fstream> #ifndef endl #define endl "\n" #endif #define wav_eco(filin, fileout, eco_rate) \ char temp[2]; \ char ch[eco_rate][2], ch2[eco_rate][2]; \ int i,j; \ for(i=0; i<eco_rate

Windows phone 8 xaudio2 wav file issue

我是研究僧i 提交于 2020-01-05 10:08:33
问题 I want play a wav file with XAudio2, I have searched on the internet and have some example projects like this: C# XAudio2 Sound Playback for Windows Phone or this: Play wav example but all those playing special wav files, if I replace my wav (converted to MS ADPCM, mono) then CreateSourceVoice return HRESULT 0x88960001. So what are specials of those wav files? or any other methods to play Wav file with xaudio2 (I'm working on windows phone 8) 回答1: According to this article, the XAudio2 only

Writing contents of a DirectSound CaptureBuffer to a WAV file in C#

可紊 提交于 2020-01-05 01:11:38
问题 I have recorded audio to a CaptureBuffer, but I can't figure out how to save it into wav file. I have tried this (http://www.tek-tips.com/faqs.cfm?fid=4782), but it didn't work, or I didn't use it properly. Does anybody know how to solve this? Sample code would be very appreciated. 回答1: A WAV file is a RIFF file consisting of two main "chunks". The first is a format chunk, describing the format of the audio. This will be what sample rate you recorded at (e.g. 44.1kHz), what bit depth (e.g. 16

Writing contents of a DirectSound CaptureBuffer to a WAV file in C#

爱⌒轻易说出口 提交于 2020-01-05 01:11:01
问题 I have recorded audio to a CaptureBuffer, but I can't figure out how to save it into wav file. I have tried this (http://www.tek-tips.com/faqs.cfm?fid=4782), but it didn't work, or I didn't use it properly. Does anybody know how to solve this? Sample code would be very appreciated. 回答1: A WAV file is a RIFF file consisting of two main "chunks". The first is a format chunk, describing the format of the audio. This will be what sample rate you recorded at (e.g. 44.1kHz), what bit depth (e.g. 16

Strip wav header in c#

半腔热情 提交于 2020-01-04 17:49:32
问题 I want to be able to strip off a header from a wav file. Is there any way to do this in C#? 回答1: WAV Files uses the standard RIFF header format. See example here. You can use this article as a starting point. It contains methods for reading and writing Wav files. Should be a simple job to strip/clear out the header info. 来源: https://stackoverflow.com/questions/1108585/strip-wav-header-in-c-sharp

What's the actual data in a WAV file?

ⅰ亾dé卋堺 提交于 2020-01-04 02:28:05
问题 I'm following the python challenge riddles, and I now need to analyse a wav file. I learn there is a python module that reads the frames, and that these frames are 16bit or 8bit. What I don't understand, is what does this bits represent? Are these values directly transformed to a voltage applied to the speakers (say via factoring)? 回答1: The bits represent the voltage level of an electrical waveform at a specific moment in time. To convert the electrical representation of a sound wave (an