Csound Csound-dev Csound-tekno Search About

[Csnd] Byte swapping in HRTF opcodes

Date2009-04-17 15:37
Fromjpff@cs.bath.ac.uk
Subject[Csnd] Byte swapping in HRTF opcodes
Following the short discussion last week about byte order in Brian Carty's
opcodes I have just committed a generic fix -- untested -- to the CVS
I do not have a BIGENDIAB machine on which to test it
==John ff


Date2009-04-17 16:45
FromAnthony Kozar
Subject[Csnd] Re: Byte swapping in HRTF opcodes
Thanks, John!  I will try to test it this weekend.

Anthony

jpff@cs.bath.ac.uk wrote on 4/17/09 10:37 AM:

> Following the short discussion last week about byte order in Brian Carty's
> opcodes I have just committed a generic fix -- untested -- to the CVS
> I do not have a BIGENDIAB machine on which to test it
> ==John ff


Date2009-04-18 21:39
FromAnthony Kozar
SubjectRe: [Cs-dev] [Csnd] Byte swapping in HRTF opcodes
jpff@cs.bath.ac.uk wrote on 4/17/09 10:37 AM:

> Following the short discussion last week about byte order in Brian Carty's
> opcodes I have just committed a generic fix -- untested -- to the CVS
> I do not have a BIGENDIAB machine on which to test it
> ==John ff

John, I've tested your solution and it seems to work.  But I think these
preprocessor tests are too limited in scope considering that nearly all CPUs
are big endian nowadays.

#ifndef WORDS_BIGENDIAN
#  if defined(__POWERPC__) || defined(__PPC__) || defined(__ppc__)
#    define WORDS_BIGENDIAN 1
#  elif defined(mac_classic)
#    define WORDS_BIGENDIAN 1
#  endif
#endif

Sconstruct already tests the endianness of the platform (1) and defines
WORDS_BIGENDIAN for the sfont module, so it seems better to be consistent
and control this from the build script.  I will change it.

I am guessing that you put the byte-swapping code in memfiles.c to avoid an
issue with multiple instances of the opcode swapping bytes more than once.
(2)  But the CSOUND_FILETYPES parameter to ldmemfile2() was not intended to
indicate that it should swap bytes.  I put this comment in csound.h when I
created the enum:

  /**
   * The following constants are used with csound->FileOpen2() and
   * csound->ldmemfile2() to specify the format of a file that is being
   * opened.  This information is passed by Csound to a host's FileOpen
   * callback and does not influence the opening operation in any other
   * way.

Since needing to process a MEMFILE struct only once could be a common
problem for opcodes, I think a version of ldmemfile2() with a callback
parameter would be a better solution than including the specialized code for
specfic opcodes directly in memfiles.c.  I will go ahead and implement this
functionality.  If you disagree with my changes, let me know.

Anthony Kozar
mailing-lists-1001 AT anthonykozar DOT net
http://anthonykozar.net/

(1) It tests endianness using Python's sys.byteorder attribute.  I think
this could be a problem for cross-compiling ...

(2) In which case, it seems likely that there is a bug along these lines in
the original hrtfer opcode.


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2009-04-20 09:05
Frombriancarty
SubjectRe: [Cs-dev] [Csnd] Byte swapping in HRTF opcodes
Many thanks for addressing this issue!
Brian
-- 
View this message in context: http://www.nabble.com/Re%3A--Csnd--Byte-swapping-in-HRTF-opcodes-tp23117117p23132099.html
Sent from the Csound - Dev mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net