wave

Sine Wave Sound Generator in Java

不问归期 提交于 2019-11-27 19:53:03
What's the simplest way to generate a sine wave sound at any frequency in Java? A sample size more than 2 bytes would help, but it doesn't really matter. Thanks Andrew Thompson See Beeper for a self-contained example. Perhaps something simpler? That 51 lines of snippet (repeated below - spaced out for single line & in-line comments) as shown at the top of the linked answer, is about as simple as generating a tone gets (OK, you can take out 5+ lines for the harmonic). People seem to assume it should be a method built into the toolkit to produce a pure tone. It is not, and takes a little

ffmpeg to convert from flac to wav

我是研究僧i 提交于 2019-11-27 14:39:29
问题 I need to convert a flac file to a wav file without changing sample rate and bit depth. As far as I know changing these properties may distort the audio, so how do i specify them not to be changed? Also, is there any way to prevent metadata to be written to the output file? 回答1: As rogerdpack commented, the command line: ffmpeg -i inputfile.flac output.wav should do exactly what you want. Addressing your concerns about keeping the resulting audio intact, FLAC is a lossless format and decoding

Detect a specific frequency/tone from raw wave-data

狂风中的少年 提交于 2019-11-27 13:42:56
I am reading a raw wave stream coming from the microphone. (This part works as I can send it to the speaker and get a nice echo.) For simplicity lets say I want to detect a DTMF-tone in the wave data. In reality I want to detect any frequency, not just those in DTMF. But I always know which frequency I am looking for. I have tried running it through FFT, but it doesn't seem very efficient if I want high accuracy in the detection (say it is there for only 20 ms). I can detect it down to an accuracy of around 200 ms. What are my options with regards to algorithms? Are there any .Net libs for it?

Downsampling wav audio file

非 Y 不嫁゛ 提交于 2019-11-27 11:46:17
问题 I have to downsample a wav file from 44100Hz to 16000Hz without using any external Python libraries, so preferably wave and/or audioop . I tried just changing the wav files framerate to 16000 by using setframerate function but that just slows down the entire recording. How can I just downsample the audio file to 16kHz and maintain the same length of the audio? 回答1: You can use Librosa's load() function, import librosa y, s = librosa.load('test.wav', sr=8000) # Downsample 44.1kHz to 8kHz The

Wav file convert to byte array in java

喜你入骨 提交于 2019-11-27 08:09:48
My project is 'Speech Recognition of Azeri speech'. I have to write a program that converts wav files to byte array. How to convert audio file to byte[]? Basically as described by the snippet in the first answer, but instead of the BufferedInputStream use AudioSystem.getAudioInputStream(File) to get the InputStream . Using the audio stream as obtained from AudioSystem will ensure that the headers are stripped, and the input file decode to a byte[] that represents the actual sound frames/samples - which can then be used for FFT etc. user1335794 Write this file into ByteArrayOutputStream

Python, How to split a .wav file into multiple .wav files

Deadly 提交于 2019-11-27 05:50:30
问题 I have a .wav file several minutes long that I would like to split into different 10 second .wav files. This is my python code so far: import wave import math def main(filename, time): read = wave.open(filename, 'r') #get sample rate frameRate = read.getframerate() #get number of frames numFrames = read.getnframes() #get duration duration = numFrames/frameRate #get all frames as a string of bytes frames = read.readframes(numFrames) #get 1 frame as a string of bytes oneFrame = read.readframes

How to write stereo wav files in Python?

半世苍凉 提交于 2019-11-26 23:08:36
问题 The following code writes a simple sine at frequency 400Hz to a mono WAV file. How should this code be changed in order to produce a stereo WAV file. The second channel should be in a different frequency. import math import wave import struct freq = 440.0 data_size = 40000 fname = "WaveTest.wav" frate = 11025.0 # framerate as a float amp = 64000.0 # multiplier for amplitude sine_list_x = [] for x in range(data_size): sine_list_x.append(math.sin(2*math.pi*freq*(x/frate))) wav_file = wave.open

Detect a specific frequency/tone from raw wave-data

别说谁变了你拦得住时间么 提交于 2019-11-26 22:23:15
问题 I am reading a raw wave stream coming from the microphone. (This part works as I can send it to the speaker and get a nice echo.) For simplicity lets say I want to detect a DTMF-tone in the wave data. In reality I want to detect any frequency, not just those in DTMF. But I always know which frequency I am looking for. I have tried running it through FFT, but it doesn't seem very efficient if I want high accuracy in the detection (say it is there for only 20 ms). I can detect it down to an

Pass Blob through ajax to generate a file

淺唱寂寞╮ 提交于 2019-11-26 18:50:29
I'm trying to capture audiorecorder ( https://github.com/cwilso/AudioRecorder ) and send the blob through Ajax a php file, which will receive the blob content and create the file(the wave file in this case). Ajax call: audioRecorder.exportWAV(function(blob) { var url = (window.URL || window.webkitURL).createObjectURL(blob); console.log(url); var filename = <?php echo $filename;?>; $.ajaxFileUpload({ url : "lib/vocal_render.php", secureuri :false, dataType : blob.type, data: blob, success: function(data, status) { if(data.status != 'error') alert("boa!"); } }); }); and my php file (vocal_render

Wav file convert to byte array in java

不羁岁月 提交于 2019-11-26 14:02:23
问题 My project is 'Speech Recognition of Azeri speech'. I have to write a program that converts wav files to byte array. How to convert audio file to byte[]? 回答1: Write this file into ByteArrayOutputStream ByteArrayOutputStream out = new ByteArrayOutputStream(); BufferedInputStream in = new BufferedInputStream(new FileInputStream(WAV_FILE)); int read; byte[] buff = new byte[1024]; while ((read = in.read(buff)) > 0) { out.write(buff, 0, read); } out.flush(); byte[] audioBytes = out.toByteArray();