Re: How can I determine volume level from data?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 20 Nov 2007, william estrada wrote:

> Bill,
>
>  You are right, I don't know what I am doing.  I am not knowledgeable enough
> to ask the right questions.  I'm looking for a reference about what the data 
> returned by the sound device means.  I found this:
>
>  http://www.cs.odu.edu/~wild/cs477/Fall97/mm1.htm
>
> But it does not completely answer  my questions.
>
>  I think my confusion is how one byte can represent all of that data?  Is

Each byte ( well, in CD standard, two bytes, or one word) represents the
amplitude of the signal at one instant of time. It is encoded as a 2 byte
signed integer. Thus the Hex bits from 0x0000 to 0x7fff represent positive
values, and bytes from 0x8000 to 0xffff represent negative values ( Ie the
top bit is the sign bit).
If it is stereo the successive words are assigned to the left and right
channels. The file at its beginning states where it is stereo or mono, and
what the speed is ( ie how fast-- stadard CD is 44100 words per channel per
second) the words should be played back. 
There are many possible encodings. Some use ulaw which is a logarithmic
encoding, while .wav encoding using linear (ie the value =amplitude). Look
at the man page for sox to get a feeling for the various possibilities, and
look in wikipedia for explanations if you are interested. 
> each
> byte a step in the 'sine wave'?  How do you know where the start, in an X,Y
> scale, where is Y-zero?  Do the drivers all ways return data starting at 
> Y-zero?
> If you get an over-run or under-run, how do you sync up?

It is simply a stream of words. If you get an overrun, you loose part of
the signal. There is no syncing. The bytes are played as fast as you tell
them to be played, one after the other.

>
>  I am not looking for an answer( 'A fish' ) as much as a reference ( 'Place 
> to
> fish' ).  I have been looking at source for SoX and record but it is still 
> not
> clear.

sox is a good place to start. Wikipedia and google are another.

>
>  I hope this is more clear?
>
>  Thanks for your time.
>
> William Estrada
> MrUmunhum@xxxxxxxxxxx
> Mt-Umunhum-Wireless.net ( http://Mt-Umunhum-Wireless.net )
> Ymessenger: MrUmunhum
>
>
>
> Bill Unruh wrote:
>>  On Mon, 19 Nov 2007, william estrada wrote:
>> 
>> >  Hi group,
>> > 
>> > 
>> >  While reading the output from my sound device, how can I determine what
>> >  the volume level is?  The options are mono, 8000, 8 bits per sample.
>> >  I have tried using volume = abs(byte-127), bit that returns either 255 
>> >  or
>> >  0.
>>
>>  No idea what you mean. The options to what? Those options look like you
>>  have your soundcard at a pretty minimal level. mono, mean mono, not
>>  stereo.
>>  8000 mean 8000 bits per second which is a bit worse than a telephone. 8
>>  bits per sample is also worse than a telephone ( that is a difference in
>>  volume levels of less than 100).
>>
>>  Maybe if you were a bit clearer or more detailed in your request.
>>
>> 
>
>

-- 
William G. Unruh   |  Canadian Institute for|     Tel: +1(604)822-3273
Physics&Astronomy  |     Advanced Research  |     Fax: +1(604)822-5324
UBC, Vancouver,BC  |   Program in Cosmology |     unruh@xxxxxxxxxxxxxx
Canada V6T 1Z1     |      and Gravity       |  www.theory.physics.ubc.ca/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user

[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux