wav

Can someone explain .wav(WAVE) file headers?

两盒软妹~` 提交于 2019-12-02 07:47:50
OK, so I'm trying to make a program that will manipulate .wav files, and I've seen this question/answers , but I'm not entirely sure as to what each piece of data in the header refers to. For example, what does a "chunk" refer to? Is that a specific number of bits/bytes? If somebody could just tell me, at least in the format used in this question, what each datum being written to the .wav, aside from the constant String Literals and the 'data' array, refer to? In particular I'd especially like to know what a "chunk" is, and how Sample Rate, Byte Rate, Bytes per Sample, and Bytes per Sample for

In Java, How do you stop a previous audio file when another audio file starts using key_events

雨燕双飞 提交于 2019-12-02 07:11:35
I know about the clip.stop() method, however it doesn't seem to work within when I have it inside the key_events. It just causes an Error. Well I know why it causes the error. Because I'm asking it to essentially stop a clip that doesn't exist until a few lines later. But using this same logic or close to it if possible, how could I recode that so it knows to select the previous clip that was playing from a previous key_event. The functionality I'm intending for is: When F1 is pressed, a wav plays. When F2 is pressed, current wav STOPS, new wav STARTS. When F3 is pressed, current wav STOPS,

Faster way to convert from 24 bit wav pcm format to float?

情到浓时终转凉″ 提交于 2019-12-02 05:39:32
问题 I need to read data in from a wav file in 24 bit pcm format, and convert to float. I'm using Python 2.7.2. The wave package reads the data in as a string, so what I've tried is: import wave import numpy as np import array import struct f = wave.open('filename.wav') # read in entire wav file wdata = f.readframes(nFrames) f.close() # unpack into signed integers and convert to float data = array.array('f') for i in range(0,nFrames*3,3): data.append(float(struct.unpack('<i', '\x00'+ wdata[i:i+3])

How to read only wav files in a directory using Python?

半世苍凉 提交于 2019-12-02 05:00:35
问题 from scipy.io.wavfile import read files = [f for f in os.listdir('.') if os.path.isfile(f)] print files for i in range(0,1): w = read(files[i]) print w I need to read only .wav files from python working directory. And store the each .wav files as a numpy array. This is my code. But in this code all files are read. I only read the wav files in the directory? How it possible? 回答1: Use the glob module and pass to it a pattern (like *.wav or whatever the files are named). It will return a list of

Workaround for UnsupportedAudioFileException?

风流意气都作罢 提交于 2019-12-02 04:43:32
I'm in a very early stage of writing a small music/rhythm game in Java (via Slick framework, which in turns uses OpenAL, but that's probably irrelevant here). The game needs to read (and playback) several sound files in WAV format, but some of the files are throwing [javax.sound.sampled.UnsupportedAudioFileException] exceptions. at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1102) at org.newdawn.slick.openal.WaveData.create(WaveData.java:123) at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:713) at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java

Comparing uint8_t data with string

旧巷老猫 提交于 2019-12-02 03:15:32
This may sounds little odd or question may be a trivial one, but for most of my life I was programming in PHP (yeah, I know how it sounds). So when I switched to C++ there are things quite unfamilliar for me (cause of php habits). So I'm loading wav header data using struct. Values are definded as uint8_t type: typedef struct WAV_HEADER { uint8_t RIFF[4]; // RIFF uint8_t WAVE[4]; // WAVE } I have to compare them with four-letter strings for something like that: if(wavHeader.RIFF[0] . wavHeader.RIFF[1] . wavHeader.RIFF[2] . wavHeader.RIFF[3] == 'RIFF') { do sth } This should be easy check if

Faster way to convert from 24 bit wav pcm format to float?

瘦欲@ 提交于 2019-12-02 02:48:37
I need to read data in from a wav file in 24 bit pcm format, and convert to float. I'm using Python 2.7.2. The wave package reads the data in as a string, so what I've tried is: import wave import numpy as np import array import struct f = wave.open('filename.wav') # read in entire wav file wdata = f.readframes(nFrames) f.close() # unpack into signed integers and convert to float data = array.array('f') for i in range(0,nFrames*3,3): data.append(float(struct.unpack('<i', '\x00'+ wdata[i:i+3])[0])) # normalize sample values data = np.array(data) data = data / 0x800000 This is quite a bit faster

QSound::play(“soundpath”) call works but a QSound object doesn't

假装没事ソ 提交于 2019-12-02 02:43:06
I am trying to play a sound with QSound module. It try with this code and works: QSound::play(":/sounds/sources/BeepSound.wav"); But I want this and doesn't work: I create a dynamic instance of QSound and played: sounds = new QSound(":/sounds/sources/BeepSound.wav"); sounds->setLoops(3); sounds->play(); Any tips? Update I don't want to use others modules like QMediaPlayer , QAudioOutput because I want something really simple, just play a sound. 来源: https://stackoverflow.com/questions/30812327/qsoundplaysoundpath-call-works-but-a-qsound-object-doesnt

Dynamically created iframe used to download file triggers onload with firebug but not without

做~自己de王妃 提交于 2019-12-02 00:47:15
问题 EDIT : as this problem is now "solved" to the point of working, I am looking to have the information on why. For the fix, see my comment below. I have an web application which repeatedly downloads wav files dynamically (after a timeout or as instructed by the user) into an iframe in order to trigger the a default audio player to play them. The application targets only FF 2 or 3. In order to determine when the file is downloaded completely, I am hoping to use the window.onload handler for the

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

狂风中的少年 提交于 2019-12-01 18:57: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 wav files play just fine. Here's the Delphi code: filename := GetEnvironmentVariable('TEMP')+'