🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.multimedia
8 messages
8 total messages Started by Fraser Ross Fri, 08 Oct 2004 08:43
zero value with samples
#373
Author: Fraser Ross
Date: Fri, 08 Oct 2004 08:43
7 lines
1160 bytes
When using sound samples that are signed 8 bit is there a midpoint value?
Since there is an even number of possible values there is not a logical
midpoint.  Should I view 0 as a positive value so that there are 128
positive values and 128 negative values or call it the midpoint and not use
the value -128?

Fraser.
Re: zero value with samples
#379
Author: Mark Jacobs
Date: Sat, 09 Oct 2004 10:50
13 lines
1556 bytes
This is what I use for 8-bit samples :-

int lv=(int)((unsigned char)wvhdr->lpData[0])-128;
-- 
Mark Jacobs

"Fraser Ross" <fraserATmembers.v21.co.unitedkingdom> wrote in message
news:4166532e@newsgroups.borland.com...
| When using sound samples that are signed 8 bit is there a midpoint value?
| Since there is an even number of possible values there is not a logical
| midpoint.  Should I view 0 as a positive value so that there are 128
| positive values and 128 negative values or call it the midpoint and not use
| the value -128?
Re: zero value with samples
#380
Author: Fraser Ross
Date: Sat, 09 Oct 2004 13:11
13 lines
1260 bytes
"Mark Jacobs"
> This is what I use for 8-bit samples :-
>
> int lv=(int)((unsigned char)wvhdr->lpData[0])-128;
> -- 

That isn't an answer to my question.  BTW I don't think the cast to int is
necessary.

My former suggestion of 128 positive values and 128 negative values and
using 0 as if it is the midpoint seems to be the norm.

Fraser.
Re: zero value with samples
#381
Author: Fraser Ross
Date: Sat, 09 Oct 2004 13:15
4 lines
1111 bytes
The midpoint is -0.5.  When rounded it is 0 so the format makes logical
sense.

Fraser.
Re: zero value with samples
#384
Author: Tom|420
Date: Tue, 26 Oct 2004 02:28
50 lines
3043 bytes
Fraser Ross wrote:

> "Mark Jacobs"
> 
>>This is what I use for 8-bit samples :-
>>
>>int lv=(int)((unsigned char)wvhdr->lpData[0])-128;
>>-- 
> 
> 
> That isn't an answer to my question.  BTW I don't think the cast to int is
> necessary.
> 
> My former suggestion of 128 positive values and 128 negative values and
> using 0 as if it is the midpoint seems to be the norm.
> 
> Fraser.
> 
> 


Yes, that answers your question, and actually in a very clear manner.

Recorded audio samples are either unsigned 8-bit or signed 16-bit. If 
there is an exception to the rule, I've never heard of it.

When dealing with signed 16-bit samples no problem. When dealing with 
unsigned 8-bit values there is an issue, which you seem to know of.

Most audio transformation algorythms are designed for signed wave forms 
and feeding them with an unsigned wave form would result in strange 
result (although some music enthousiasts like strange result). Therefore 
you want to convert the unsigned wave form into a signed one. To do this 
you substract 128 ((2^8)/2) from you unsigned samples as you transfer 
them into a signed container. No mathematician could deny that formula, 
it's basic arythmetic. Knowing the middle-point is irrelevant. There is 
no middle-point in an audio sample. If you believe a middle-point would 
be a point of silence you are off-track. Don't forget to transfer your 
samples into unsigned container when done processing before you try to 
play it back.

Mark Jacobs answer is the only good answer to your question. If you 
don't trust that answer do some research (although you will probably 
find that audio experts don't publish much free stuff on the net -- 
actualy they don't even publish much for-a-fee stuff anywhere).


Hope this helps and have fun with your audio samples,

Tom :)
Re: zero value with samples
#385
Author: Mark Jacobs
Date: Tue, 26 Oct 2004 09:08
23 lines
2206 bytes
Thanks Tom. That formula certainly works on all PC systems I've ever tried it
on! Example apps using 8-bit unsigned samples are in VU meters at
http://www.jacobsm.com/index.htm#sft - look at MJ Player and MJ Calculator.
-- 
Mark Jacobs

"Tom|420" <tom420.duhamel@gmail.com> wrote in message
news:417db647$1@newsgroups.borland.com...
| Fraser Ross wrote:
|
| > "Mark Jacobs"
| >>This is what I use for 8-bit samples :-
| >>int lv=(int)((unsigned char)wvhdr->lpData[0])-128;
| >
| > That isn't an answer to my question.  BTW I don't think the cast to int is
| > necessary.
| > My former suggestion of 128 positive values and 128 negative values and
| > using 0 as if it is the midpoint seems to be the norm.
|
| Mark Jacobs answer is the only good answer to your question. If you
| don't trust that answer do some research (although you will probably
| find that audio experts don't publish much free stuff on the net -- 
| actualy they don't even publish much for-a-fee stuff anywhere).
Re: zero value with samples
#387
Author: Tom|420
Date: Tue, 26 Oct 2004 23:31
19 lines
2200 bytes
Mark Jacobs wrote:

> Thanks Tom. That formula certainly works on all PC systems I've ever tried it
> on! Example apps using 8-bit unsigned samples are in VU meters at
> http://www.jacobsm.com/index.htm#sft - look at MJ Player and MJ Calculator.

No problem sir. I hate that when someone doesn't trust an answer which I 
know is right. May I suggest that you explain your answers in the 
future? I must admit that I don't always trust an answer given just as 
plain as this. Often, even if you don't understand the explanations, you 
at least know that the person who answered knows what he is talking about.

I visited you website last night, and I must blame it to be the cause of 
getting to bed too late :P  I like you philosphy. Didn't try your 
software but I should eventually.

Have a nice day

Tom :)
Re: zero value with samples
#388
Author: Fraser Ross
Date: Fri, 05 Nov 2004 10:09
4 lines
1174 bytes
The formula does not answer my question.  I did not even mention unsigned 8
bit values or any 16 bit values.

Fraser.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads