Posted: 06 Jun 2010, 10:55
I try to pack some midi data to some 32bit number, for then to unpack to reduce my array size by 4.(but maybe useless?)
so I take ch+(msg*$100)+(code1*$10000)+(code2*$1000000) on input that goes to a script that use
shr,shr8,shr16,shr24 and that seems to work, but if the last byte(code2) is more than 0, the decoded channel (first byte)mess.
I suppose it's something linked to the fact that then the 16777216 wich multiply the 4rd byte is the Max possible integer?
Is there something special to do, or is it that general datas/tparameter are maxed to 24bits cause of the mantissa thing once
spoke about?
i manage to pack/unpack 24bits but not 32, is it possible?
here is the script:
so I take ch+(msg*$100)+(code1*$10000)+(code2*$1000000) on input that goes to a script that use
shr,shr8,shr16,shr24 and that seems to work, but if the last byte(code2) is more than 0, the decoded channel (first byte)mess.
I suppose it's something linked to the fact that then the 16777216 wich multiply the 4rd byte is the Max possible integer?
Is there something special to do, or is it that general datas/tparameter are maxed to 24bits cause of the mantissa thing once
spoke about?
i manage to pack/unpack 24bits but not 32, is it possible?
here is the script:
var midi_32bits : Tparameter;
var ch,msg,code1,code2 : Tparameter;
// initialisation : create parameters
procedure init;
begin
midi_32bits := CreateParam('midi_32bits',ptDataField);setMax(midi_32bits,$100000000);
Ch := CreateParam('Ch',ptDataField);
Msg := CreateParam('msg',ptDataField);
code1 := CreateParam('code1',ptDataField);
code2 := CreateParam('code2',ptDataField);
SetIsOutPut(midi_32bits,false);
SetIsinPut(Ch,false);
SetIsInPut(Msg,false);
SetIsInPut(Code1,false);
SetIsInPut(Code2,false);
end;
procedure Callback(n:integer);
begin
if (n=midi_32bits) then DECODE_MIDI;
end;
// no process bloc
/////////////////////////////////////////////////
Procedure Decode_Midi;
var valout: dword;
BEGIN
valout:= round(getvalue(midi_32bits));
setvalue(CH, GetChValue(valout));
setvalue(MSG, GetMSGValue(valout));
setvalue(Code1, GetCode1Value(valout));
setvalue(Code2, GetCode2Value(valout));
END;
///////////////////////////////////////
function GetCHValue(midi: DWORD): Byte;
begin
Result := Byte(midi);
end;
///////////////////////////////////////
function GetMSGValue(midi: DWORD): Byte;
begin
Result := Byte(midi shr;
end;
///////////////////////////////////////
function GetCode1Value(midi: DWORD): Byte;
begin
Result := Byte(midi shr 16);
end;
////////////////////////////////////
function GetCode2Value(midi: DWORD): Byte;
begin
Result := Byte(midi shr 24);
end;
////////////////////////////////////]