A Audio, hi-fi and car audio  forum. Audio Banter

Go Back   Home » Audio Banter forum » UK Audio Newsgroups » uk.rec.audio (General Audio and Hi-Fi)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

uk.rec.audio (General Audio and Hi-Fi) (uk.rec.audio) Discussion and exchange of hi-fi audio equipment.

Tubey techy tidbit.....



 
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old February 7th 10, 09:04 PM posted to uk.rec.audio
Chris Isbell
external usenet poster
 
Posts: 126
Default Tubey techy tidbit.....

On Sun, 07 Feb 2010 12:42:53 +0000 (GMT), Jim Lesurf
wrote:

Must admit that I have long been used to 'int' being signed 32 bit by
default. So I was surprised more recently to see how common it was for x86
GCC and Linux, Doze, etc, to tend to use 16 bit by default. With GCC I use
'long' (32 bit) for any audio values that are integers. (And I have always
used 'double' for floating points.)


From memory (my copy of K&R is at work), int must be at least sixteen
bits and long at least thirty-two bits. When people assume 16 bits
for int values it causes portability problems. I have quite a lot of
experience of this from developing software for sixteen-bit
microcontrollers.

--
Chris Isbell
Southampton, UK
  #2 (permalink)  
Old February 8th 10, 08:27 AM posted to uk.rec.audio
Jim Lesurf[_2_]
external usenet poster
 
Posts: 2,668
Default Tubey techy tidbit.....

In article , Chris Isbell
wrote:
On Sun, 07 Feb 2010 12:42:53 +0000 (GMT), Jim Lesurf
wrote:


Must admit that I have long been used to 'int' being signed 32 bit by
default. So I was surprised more recently to see how common it was for
x86 GCC and Linux, Doze, etc, to tend to use 16 bit by default. With
GCC I use 'long' (32 bit) for any audio values that are integers. (And
I have always used 'double' for floating points.)


From memory (my copy of K&R is at work), int must be at least sixteen
bits and long at least thirty-two bits.


Yes, page 36 in my copy (2nd edition).

When people assume 16 bits for int values it causes portability
problems. I have quite a lot of experience of this from developing
software for sixteen-bit microcontrollers.


Overally, I largely jumped over that, I guess. Went directly from BBC B etc
to 32/26 bit ARM.

However the curious thing for me is that - IIUC - GCC assumes 16 bits for
'int' even on machines with 32 bit CPUs. That clashes with what K&R wrote
higher up the same page as above - that the choice for 'int' should be what
is natural for the machine. But I only recently noticed this quirk when I
started writing Linux apps to process audio data files.

That also caused me to use my first 'unsigned long' to cope with handling
the size of a very large LPCM file! Using 'long' returned the result that
the WAV file had a negative payload! 8-]

So it does seem plausible that the 'clips at -6dB for mono' effect that was
reported was due to inappropriate use of 16bit ints. As you say, maybe
because the same source code works OK on other platforms this has passed
unnoticed by the writers.

Personally, it tends to comfirm my own preference for writing my own code
when I can - albeit making my own mistakes in the process! :-)

Slainte,

Jim

--
Please use the address on the audiomisc page if you wish to email me.
Electronics http://www.st-and.ac.uk/~www_pa/Scot...o/electron.htm
Armstrong Audio http://www.audiomisc.co.uk/Armstrong/armstrong.html
Audio Misc http://www.audiomisc.co.uk/index.html

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:45 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.SEO by vBSEO 3.0.0
Copyright ©2004-2025 Audio Banter.
The comments are property of their posters.