wav

Creating a stereo WAV file using C

痴心易碎 提交于 2019-12-03 09:07:43
I am looking at creating a WAV file in C and have seen an example here . This looks good, but I'm interested in adding two buffers to make the audio stereo (the possibility to have different sound in each ear) . If I set the number of channels to two, the audio plays out of the left channel only (which apparently is right, as the left channel is the first channel). I have read I must interleave it with the right channel. Unfortunately I haven't found much online to help create a stereo WAV. write_little_endian((unsigned int)(data[i]),bytes_per_sample, wav_file); I've tried to create a second

Android Record raw bytes into WAVE file for Http Streaming

柔情痞子 提交于 2019-12-03 09:03:56
So I am using AudioRecord from Android to record raw bytes and for writing them into a .wav file. Since Android has no support for this I had to write the .wav file headers manually with the following code: randomAccessWriter.writeBytes("RIFF"); randomAccessWriter.writeInt(0); // Final file size not known yet, write 0 randomAccessWriter.writeBytes("WAVE"); randomAccessWriter.writeBytes("fmt "); randomAccessWriter.writeInt(Integer.reverseBytes(16)); // Sub-chunk size, 16 for PCM randomAccessWriter.writeShort(Short.reverseBytes((short) 1)); // AudioFormat, 1 for PCM randomAccessWriter.writeShort

Recording a wav file from the mic in Android - problems

拜拜、爱过 提交于 2019-12-03 07:56:36
问题 I need to be able to create a WAV file using the mic in Android. Currently, I'm having a lot of trouble. So far, this is my situation. I'm using parts of the micDroid project code to record thus: //read thread int sampleRate = 44100; int bufferSize = AudioRecord.getMinBufferSize(sampleRate,android.media.AudioFormat.CHANNEL_CONFIGURATION_MONO,android.media.AudioFormat.ENCODING_PCM_16BIT); AudioRecord ar = new AudioRecord(AudioSource.MIC,sampleRate,android.media.AudioFormat.CHANNEL

processing an audio wav file with C

醉酒当歌 提交于 2019-12-03 07:46:00
问题 I'm working on processing the amplitude of a wav file and scaling it by some decimal factor. I'm trying to wrap my head around how to read and re-write the file in a memory-efficient way while also trying to tackle the nuances of the language (I'm new to C). The file can be in either an 8- or 16-bit format. The way I thought of doing this is by first reading the header data into some pre-defined struct, and then processing the actual data in a loop where I'll read a chunk of data into a

Analyzing wav and drawing a graph

情到浓时终转凉″ 提交于 2019-12-03 07:40:14
问题 I'm trying to print out an wave from a wav file, but I'm kinda lost on how the length I should take for an sample. this is what I would love to archieve (without the colors): so for reading in my data I use the following code: // first we need to read our wav file, so we can get our info: byte[] wav = File.ReadAllBytes(filename); // then we are going to get our file's info info.NumChannnels = wav[22]; info.SampleRate = bytesToInt(wav[24], wav[25]); // nr of samples is the length - the 44

How can I convert between midi to wav/mp3 in c#?

两盒软妹~` 提交于 2019-12-03 06:54:13
I started a small project which includes working with MIDI files. I've been wondering, is there any C# or VB.Net code that peforms that cast between MIDI and WAV files? You could try to somehow interface with Timidity , which is Open Source: TiMidity++ is a software synthesizer. It can play MIDI files by converting them into PCM waveform data; give it a MIDI data along with digital instrument data files, then it synthesizes them in real-time, and plays. It can not only play sounds, but also can save the generated waveforms into hard disks as various audio file formats. FluidSynth is a more

How to convert wav to flac from python?

五迷三道 提交于 2019-12-03 06:48:08
I've just started using Python and am using the PyAudio and Wave modules to take sound from my microphone and convert it to a .wav file. What I'm trying to do is now convert that .wav to a .flac . I've seen a few ways to do this which all involve installing a converter and placing it in my environmental PATH and calling it via os.system . Are there any other ways to convert a .wav to a .flac via Python? The solution I'm looking for needs to work on both Windows and Linux. May be you're looking for Python Audio Tools. It seems PAT can do whatever you want. I have not tested this solution but

How to extract frequency out of WAV sample data?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 06:25:42
问题 I'm developing an application in c to read simple PCM WAV files. My question is, how should I interpret the samples from the data chunk, so that I can extract the sample's frequency? Given a WAV example, how can the original data represent frequencies. E.g. this data chunk, 24 17 1e f3, for stereo, 16 bits, the left channel sample is, 0x1724 = 5924d, means 5924Hz ? How can that be, for samples that are signed or frequencies that humans can´t hear? 回答1: Your assumption is incorrect. The sample

Web Audio API - record to MP3?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 05:06:28
问题 I am asking because I couldn't find the answer anywhere. I have successfully implemented RecorderJS in order to record microphone input in JS. However, the recorded file is WAV which results in large files. I am looking for a way to record with JS directly to MP3, or encode the bits somehow to MP3 instead of WAV. How can it be done? Is there a Web Audio API function that can do that or JS MP3 encoder of some sort? 回答1: The only Javascript MP3 encoder I've seen is https://github.com/akrennmair

How do I attenuate a WAV file by a given decibel value?

本小妞迷上赌 提交于 2019-12-03 04:38:43
问题 If I wanted to reduce a WAV file's amplitude by 25%, I would write something like this: for (int i = 0; i < data.Length; i++) { data[i] *= 0.75; } A lot of the articles I read on audio techniques, however, discuss amplitude in terms of decibels. I understand the logarithmic nature of decibel units in principle, but not so much in terms of actual code. My question is: if I wanted to attenuate the volume of a WAV file by, say, 20 decibels, how would I do this in code like my above example?