Xojo Conferences
XDCMay2019MiamiUSA

[MBS] MemoryBlock.SwapBytesMBS... (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] 4.0dr4
Next thread: [MBS] TIFF, Alpha Channels


Re: [MBS] MIDI Destinations and External Devices   -   Ron Benditt
  [MBS] MemoryBlock.SwapBytesMBS...   -   Ray Giarratana
   Re: [MBS] MemoryBlock.SwapBytesMBS...   -   Christian Schmitz
    Re: [MBS] MemoryBlock.SwapBytesMBS...   -   Ray Giarratana

[MBS] MemoryBlock.SwapBytesMBS...
Date: 19.01.04 06:08 (Sun, 18 Jan 2004 23:08:27 -0600)
From: Ray Giarratana
Hey there,

I'm writing a little code to convert a SoundFont to multiple AIFF files.
SoundFonts are typically LittleEndian and AIFF's are BigEndian. So, after I
got it all working, I realized I needed to reverse the bytes.

So I called:

memoryBlock.SwapBytesMBS 0, memoryBlock.size

This seemed to do the trick, but it also reversed the entire sample start to
end! Meaning, the bytes are now in the write order, but the sample plays
backwards.

Am I doing something wrong? Or might there be a bug in the code?

I tried using my own (slow!) RB code below, to reverse the bytes and it
worked properly.

Sub MySwapBytes(mb as MemoryBlock)
dim i, tmp as integer

for i = 0 to mb.size-1 step 2
tmp = mb.Byte(i)
mb.byte(i) = mb.byte(i+1)
mb.byte(i+1) = tmp
next
End Sub

Thanks!

Re: [MBS] MemoryBlock.SwapBytesMBS...
Date: 19.01.04 19:58 (Mon, 19 Jan 2004 19:58:10 +0100)
From: Christian Schmitz
Ray Giarratana <<email address removed>> wrote:

> This seemed to do the trick, but it also reversed the entire sample start to
> end!

That's what it should do, but for you I just added Swapbytes16 and
Swapbytes32 which swap in 2 or 4 bytes chunks.

Mfg
Christian

Re: [MBS] MemoryBlock.SwapBytesMBS...
Date: 19.01.04 22:49 (Mon, 19 Jan 2004 15:49:15 -0600)
From: Ray Giarratana
Thank you!



On 1/19/04 12:58 PM, "Christian Schmitz" <<email address removed>>
wrote:

> Ray Giarratana <<email address removed>> wrote:
>
>> This seemed to do the trick, but it also reversed the entire sample start to
>> end!
>
> That's what it should do, but for you I just added Swapbytes16 and
> Swapbytes32 which swap in 2 or 4 bytes chunks.
>
> Mfg
> Christian