wav

Play sound directly from byte array - Java

≯℡__Kan透↙ 提交于 2019-12-01 09:56:04
问题 I'm trying to play a sound that is stored as a byte-array using the following method: byte[] clickSamples = getAudioFileData("sound.wav"); ByteBuffer buffer = ByteBuffer.allocate(bufferSize*2); int tick = 0; for (int i = 0; i < clickSamples.length; i++) { buffer.putShort((short) clickSamples[i]); tick++; if (tick >= bufferSize/SAMPLE_SIZE) { line.write(buffer.array(), 0, buffer.position()); buffer.clear(); tick = 0; } } It's kind of hard to explain what's going wrong. I'm getting a sound but

Android AudioTrack clicks at start and end of sound

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 08:49:59
I get clicks at the start and end of playing a sound (a wav from the sdcard). It must be something to do with the track buffering but I dont know the solution. Also, I create a new one of these every time the sound plays, is this ok or is there a better way? There are many sounds playing over and over. Here is the code: public void PlayAudioTrack(final String filePath, final Float f) throws IOException { new Thread(new Runnable() { public void run() { //play sound here int minSize = AudioTrack.getMinBufferSize( 44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT );

What exactly is the data returned when reading a .wav file?

无人久伴 提交于 2019-12-01 08:36:51
When reading a audio file using something such as rate, wavData = scipy.io.wavfile.read('test.wav') what exactly does the data inside of wavData represent? wavData is an array of numbers each representing a single sample of the audio signal. The samples are snapshots of the audio amplitude spaced evenly in time. So if your rate is returned as 48000 then the first 48000 elements of wavData would be 1 second worth of the audio signal. For more information read about PCM on wikipedia: https://en.wikipedia.org/wiki/Pulse-code_modulation . 来源: https://stackoverflow.com/questions/33640274/what

Issues with scipy.io wave file processing after applying fourier transforms

前提是你 提交于 2019-12-01 08:14:29
问题 I'm working with some audio files in Python using scipy.fftpack and scipy.io packages. What this implies is I have wave files that I am importing, playing around with them using Fourier transforms, and then outputting to a new wave file. I am however having running into issues where in after running these transforms, the wave file will not play and is roughly 4 times the size of the original file. Currently I'm just importing the song, taking the rate, data pieces from the import, doing ifft

Android AudioTrack clicks at start and end of sound

拟墨画扇 提交于 2019-12-01 07:46:00
问题 I get clicks at the start and end of playing a sound (a wav from the sdcard). It must be something to do with the track buffering but I dont know the solution. Also, I create a new one of these every time the sound plays, is this ok or is there a better way? There are many sounds playing over and over. Here is the code: public void PlayAudioTrack(final String filePath, final Float f) throws IOException { new Thread(new Runnable() { public void run() { //play sound here int minSize =

Wav audio file compression not working

こ雲淡風輕ζ 提交于 2019-12-01 06:47:01
Is it possible to compress a wav audio file without reducing the sampling rate? I have an audio file with 256 bit rate and sampling rate - 8000Hz. I would just like to reduce the bit rate to 128/64 kbs I tried converting to mp3 and back to wav, ffmpeg -i input.wav 1.mp3 ffmpeg -i "1.mp3" -acodec pcm_s16le -ar 4000 out.wav but this reduced sampling rate as well. ffmpeg -i "1.mp3" -acodec pcm_s16le -ab 128 out.wav has default 256 bit rate PCM ("WAV") is uncompressed, so -b:a / -ab is ignored. Calculating PCM bitrate Assuming a stereo input, 8000 samples per second, 16 bits per sample: sample

Java: Mixing two WAV files without introducing noise

一曲冷凌霜 提交于 2019-12-01 06:34:42
问题 I'm trying to mix 2 WAV files into a single WAV file. The files will always be the exact same duration and have the same format (16 bit, 44.1 kHz, signed, little endian, mono). Both WAVs are put into to byte arrays using a ByteArrayOutputStream using AudioSystem.getAudioInputSream to ensure I'm just getting the PCM data and no headers. With the help of a few other threads, I've been able to successfully combine the arrays, but not without introducing a significant amount of noise to the

Trying to get the frequencies of a .wav file in Python

家住魔仙堡 提交于 2019-12-01 06:27:15
I know that questions about .wav files in Python have been just about beaten to death, but I am extremely frustrated as no one's answer seems to be working for me. What I'm trying to do seems relatively simple to me: I want to know exactly what frequencies there are in a .wav file at given times. I want to know, for example, "from the time n milliseconds to n + 10 milliseconds, the average frequency of the sound was x hertz". I have seen people talking about Fourier transforms and Goertzel algorithms, as well as various modules, that I can't seem to figure out how to get to do what I've

How to concatenate WAV files in C#

天涯浪子 提交于 2019-12-01 06:21:17
I have 2 wav files that I want to concatenate into one file with the two sound tracks. Is there any api for that task or some built in commands in .NET that can I can use in some genius way to make this task possible? Many thanks for the help. :) If I'm not mistaken, you can just append the bytes from the second file to the end of the first. If there is any header data, you'll want to exclude that (see here ) Be advised that you may hear a click or pop between the two clips, as there will be no blending. You could probably get around this by fading (gradually reducing the values for the last

reading a WAV file from TIMIT database in python

风格不统一 提交于 2019-12-01 05:55:22
I'm trying to read a wav file from the TIMIT database in python but I get an error: When I'm using wave: wave.Error: file does not start with RIFF id When I'm using scipy: ValueError: File format b'NIST'... not understood. and when I'm using librosa, the program got stuck. I tried to convert it to wav using sox: cmd = "sox " + wav_file + " -t wav " + new_wav subprocess.call(cmd, shell=True) and it didn't help. I saw an old answer referencing to the package scikits.audiolab but it looks like it is no longer supported. How can I read these file to get a ndarray of the data? Thanks Your file is