At this link http://stackoverflow.com/questions/15087668/how-to-convert-pcm-samples-in-byte-array-as-floating-point-numbers-in-the-range?noredirect=1&lq=1itit says the " range of 16 bit integers is -32768 to 32767" however in your code you are always multiplying by 32768 and the max range looks like it is65536 (should this be 65535?). Are you taking a different approach here or am I missing something? I notice when I do a null test it zero’s completely except for a small section where the sine wave reaches it’s peak value.
Also you mention ‘endiness’ and on the wikipedia page for aiff https://en.wikipedia.org/wiki/Audio_Interchange_File_Format itsays “With the development of theMac OS Xoperating system, Apple created a new type of AIFF which is, in effect, an alternativelittle-endianbyte order format.”- Therefore is your code here creating a 'little-endian" format of the aiff?
Yep, that’s fair questions afta8. About the multiplier, yes it probably is 65535 rather than 65536, so if it produces better PCM values around zero then by all means change that, no trouble. I just quickly guessed, not much thought applied on my part there afta8
Now the ‘endiness’ business… At the moment the code produces a big endian PCM data stream. Old style Amiga/Apple probably favoured this as they were Motorola 680x0 based machines, where the processor architecture was big endian. However I think what wiki is saying is that because Apple moved to Intel x32/x64 processors which are little endian in nature, Apple changed the AIFF file format to accommodate this. Now your OP-1? Does it want little or big endian stream? I don’t own a OP-1 afta8 but with the file I have here it seems to me to want a little endian PCM stream. Luckily it shouldn’t be a problem because all you do is to swap this:
--This is big endian...
data[dptr] = string.char(bit.band(bit.rshift(SampNumber,8),0xff))
dptr = dptr + 1
data[dptr] = string.char(bit.band(SampNumber,0xff))
dptr = dptr + 1
To this:
--This is little endian...
data[dptr] = string.char(bit.band(SampNumber,0xff))
dptr = dptr + 1
data[dptr] = string.char(bit.band(bit.rshift(SampNumber,8),0xff))
dptr = dptr + 1
But you would have to try that when you get to the stage of uploading a sample to your OP-1
I’m not an expert on the AIFF file format, but I assume there is something in the header that tells it what ‘endiness’ the stream is in afta8.
[Edit: Yes there is, I can see it here in this file The other thing to mention is that when you do start to modify the header afta8, I don’t think Renoise can load any other format of AIFF other than standard ‘old style’ big endian format. So you would probably have to use another program to load those AIFF files. Ah, hello Djeroek :)]