How do i sample an audio file say .wav , in an 8 bit 8khz parameter - audio

i am not that big on programming and i need to sample an audio file that is recorded via a mobile, i understand that the mobile device records the voice, and there are sample rates and each sample has a 8bit or 16 bit sample size. i need 8 bit sample size in 8khz. the programming environment is lua but that doesnt matter really the basic deal is sampling. Any help would be appreciated.

You need to either set your recording parameters at the time that you record the sound sample to 8 bits # 8 kHz, or, if you can't, or don't have any control over the actual recording process, then you will need to resample the original recording to get it into the format that you need. You can do this off-line with a tool such as SoX, or you can write code that does this on-the-fly. If you give more detail in your question then I can add more specific detail in my answer.

I don't know about lua, but as suggested by Paul R, you can always post-process your audio files using SoX or ffmpeg. On linux, just install ffmpeg :
sudo apt-get install ffmpeg
Then :
ffmpeg -i trenet.wav -ar 8000 trenet-8k.wav
This resamples your audio at 8000 Hz. I did not find how to deal with the bits/sample parameter but you can always tune the bitrate. For documentation :
man ffmpeg

Related

File information of .raw audio files using terminal in linux

How to get file information like sampling rate, bit rate etc of .raw audio files using terminal in linux? Soxi works for .wav files but it isn't working for .raw.
If your life depended on discovering an answer you could make some assumption to tease apart the unknowns ... however there is no automated way since the missing header would give you the easy answers ...
The audio analysis tool called audacity allows you to open up a RAW file, make some guesses and play the track
http://www.audacityteam.org
In audacity goto File -> Import -> Raw Data...
Above settings are typical for audio ripped from a CD ... toy with trying stereo vs mono for starters.
Those picklist widgets give you wiggle room to discover the format of your PCM audio given that the source audio is something when properly rendered is recognizable ... would be harder if the actual audio was noise
However if you need a programmatic method then rolling your own solution to ask those same questions which appear in above window is possible ... is that what you need or will audacity work for you ? We can go down the road of writing code to play off the unknowns mentioned in #Frank Lauterwald's comment
To kick start discovering this information programmatically, if the binary raw audio is 16 bit then each audio sample (point on the audio curve) will consume two bytes of your PCM file. For mono audio then the following two bytes would be your next sample, however if its stereo then these two following bytes would be the sample from the other channel. If more than two channels then just repeat. Typical audio is little endian. Sampling rate is important when rendering the audio, not when programmatically parsing raw bytes. One approach would be to create an output file with a WAV header followed by your source PCM data. Populate the header with answers from your guesswork. This way you could listen to this output file to help confirm your guesses.
Here is a sample 500k mono PCM audio file signed 16 bit which can be imported into audacity or used as input to rolling your own identification code
The_Constructus_Corporation_Long_Street-ycexQvMy03k_excerpt_mono.pcm

HE-AAC Conversion

guys!
I've been asked at work to prepare a large audio library for tests, which includes different files of HE-AACv1 & HE-AACv2. To be specific, all sample rates from 8000 up to 48000 and bit rates from 8 bit to 32 bit. But I've been digging the internet for a while and can't find the exact information. Is it even possible to make HE-AAC with 8KHz sample rate? And are there any tools that allow to directly set this specific values (bit rate and sample rate)? I've tried adobe audition, audacity and a bunch of something I found on google, but neither gives me opportunities that I need, or it's just me being dumb.
Please, if you know the way to create a HE-AACv1 and v2 from for example mp3 or wav, tell me how to do it, I would be very grateful.
Thx!
Adobe Audition can definitely create all WAVs that you need, look under "Edit->Convert sample type". You should first create your wav files, and then use some encoder to transcode to AAC.

Converting From 4-bit RAW Audio to WAV (or another output format)

Okay, so I've got some .raw files from an old game (Zork Nemesis) and determined that they're audio files, however I'm having trouble converting them into something meaningful.
With a bit of trial and error in Audacity I've found that I can listen to a still noisy version of the audio using raw file input settings of 8-bit signed PCM in stereo with a sample rate of 22050hz. However, my suspicion is that the files may in fact be encoded in 4-bits with a sample rate of 44100hz, but I'm having trouble finding a tool that can handle this.
What I'm looking for is either a tool that can handle 4-bit raw formats, or even a tool that can determine (or guess at) the format of a given .raw file, so I know for sure what I'm dealing with (as I'm just going by trial and error so far).
I've tried sox, but I'm most likely doing something wrong as it complains of an unsupported size:
sox -r 44100 -e signed -b 4 -c 2 in.raw out.wav
I was also going to try ffmpeg, but I can't find the appropriate format/codec to set.
In case it gives any further clues; I've tried various combinations of settings, increasing sample size while decreasing sample rate increases the (white-)noise, and even 8-bit is still noisy, which is why I'm thinking 4-bit. I've tried signed and unsigned, which strangely doesn't seem to make much of a difference
sox expects .raw input with 8-bit or higher encoding. So if you run
sox -r 44100 -e signed -b 8 -c 2 in.raw out.wav
it should work just fine. So either the file is actually 8(+)-bit encoded or you need find a converter which accepts this form of input.

Include simple sound in iphone app

I searched many questions - but no one seems to be giving simplest, most uniform approach, hence please do not close as duplicate.
My requirement is simple: I have quiz app.
I want to include:
background music that plays continually - probably more than one
audio.
I need occassional sounds played at specific events - they
are very short in duration. Maybe 4-5 in number.
What sound format do I use? [aac etc]
How do I produce it? (optionally, get it from internet, if free)
What is the best approach to incorporate it? [audioplayback, openal etc)
Forgive me if this is quite stupid, but I am going very generic here and can't seem to find it.
Thanks for the help!
For sound format, use AAC or uncompressed 16-bit little endian in a CAF container (avoid mp3 since it's difficult to make it loop cleanly). You can convert using the command line tool 'afconvert':
Compressed:
afconvert -f caff -d aac sourcefile.wav destfile.caf
Uncompressed 16-bit:
afconvert -f caff -d LEI16 sourcefile.wav destfile.caf
For production, either record it yourself (using an audio program such as Audacity), get a professional to do it, or buy royalty free sounds/music.
To incorporate it, use AVAudioPlayer for music and OpenAL for sounds. OpenAL is difficult to use and doesn't decode compressed audio on its own, so you may want to use an audio library such as https://github.com/kstenerud/ObjectAL-for-iPhone

Mix Audio tracks with offset in SOX

From ASP.Net, I am using FFMPEG to convert flv files on a Flash Media Server to wavs that I need to mix into a single MP3 file. I originally attempted this entirely with FFMPEG but eventually gave up on the mixing step because I don't believe it it possible to combine audio only tracks into a single result file. I would love to be wrong.
I am now using FFMPEG to access the FLV files and extract the audio track to wav so that SOX can mix them. The problem is that I must offset one of the audio tracks by a few seconds so that they are synchronized. Each file is one half of a conversation between a student and a teacher. For example teacher.wav might need to begin 3.3 seconds after student.wav. I can only figure out how to mix the files with SOX where both tracks begin at the same time.
My best attempt at this point is:
ffmpeg -y -i rtmp://server/appName/instance/student.flv -ac 1 student.wav
ffmpeg -y -i rtmp://server/appName/instance/teacher.flv -ac 1 teacher.wav
sox -m student.wav teacher.wav combined.mp3 splice 3.3
These tools (FFMEG/SoX) were chosen based on my best research, but are not required. Any working solution would allow an ASP.Net service to input the two FMS flvs and create a combined MP3 using open-source or free tools.
EDIT:
I was able to offset the files using the delay switch in SOX.
sox -M student.wav teacher.wav combined.mp3 delay 2.8
I'm leaving the question open in case someone has a better approach than the combined FFMPEG/SOX solution.
For what it's worth, this should be possible with a combination of -itsoffset and the amix filter, but a bug with -itsoffset prevents it. If it worked, the command would look something like this:
ffmpeg -i student.flv -itsoffset 3.3 -i teacher.flv -vn -filter_complex amix out.mp3
mixing can be pretty simple: how to mix two audio channels?
well i suggest you should use flash.
it may sounds weird, correct me if im wrong but with Flash's new multimedia abilities you can mix a couple tracks.
im not sure, but i'm just trying to help you,
theese 2 link can help you for your aim (specially second link i guess);
http://3d2f.com/programs/25-187-swf-to-mp3-converter-download.shtml
http://blog.debit.nl/2009/02/mp3-to-swf-converter-in-actionscript-3/

Resources