do nebody hv ne idea how to find bit pattern of an audio file ???

Dani AI

Generated

asked for a "bit pattern" but the question needs one key detail: the file format. and are right that the question should be clearer, and is right to ask which format. "Bit pattern" can mean two different things: (A) the raw bytes inside the container file (what a hex editor shows), or (B) the decoded sample values (PCM samples) that represent the sound waveform. The approach differs depending on which you want.

A pragmatic Java workflow to get the decoded bytes is to open the file with Java Sound, inspect the AudioFormat, then read the bytes from an AudioInputStream. The AudioFormat tells you sample size, channels, endianness and whether the samples are PCM signed or unsigned. If the encoding is PCM, the bytes you read are the sample bytes and can be converted to numeric samples for analysis. See the Java AudioFormat docs for details: AudioFormat

Example notes (no full program here): call AudioSystem.getAudioInputStream(file) to get an AudioInputStream, then examine fmt.getSampleSizeInBits(), fmt.isBigEndian(), fmt.getEncoding() and fmt.getFrameSize(). For 16-bit little-endian PCM, reconstruct a sample from two bytes like:

int sample = ((buffer[i+1] & 0xff) << 8) | (buffer[i] & 0xff);
short s = (short) sample;

Remember: for stereo frames are interleaved (L,R,L,R), 8-bit PCM is commonly unsigned, and endianness matters. If the file is compressed (MP3/AAC), Java SE may not decode it by default — use a decoder library (or convert to WAV with ffmpeg/Audacity) before inspecting samples. To view raw container bytes instead of decoded samples, use a hex tool (hexdump, xxd, HxD).

Recommended Answers

All 3 Replies

Not everyone here understands IM messages...Please post full/complete/comprehendible questions!

zandiago is right. You are having so many questions in C, C++ & Java at a time. And half of them are ill-framed, the other half insisting others to do your homework.

And you really need to specify the format of the audio file you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.