adpcm compression - developement stuffs

Started by Zenon, April 16, 2010, 18:04:40

Previous topic - Next topic

Zenon

finally...

for (uint i = 0; i < sampleWav.Length; ++i)
           {
               int s_new = sampleWav[i];
               int s_diff = (int)(s_new - s_old); // should be unsigned; if possible, use uint8 or uint8_t or whatever it's called in c# for more clarity.

               writer.Write((sbyte)s_diff);

               s_old = s_new;
           }
Xrns2XMod converter
http://xrns2xmod.codeplex.com

Zenon

Speaking of MOD, I read that samples are stored in signed bytes, but I haven't figured out how.

I tried with original chunk data (bad result) and encoded data like XM's way (near to original but not the same).

Who knows how exactly sample data is stored ?  :?:
Xrns2XMod converter
http://xrns2xmod.codeplex.com

Saga Musix

You might want to try adding 0x80 to all values before converting them to signed bytes, although I'm really sure if that would be of any help, but it's worth a try at least.
Some general hints:
1) The sample length MUST be even (add a zero byte if it's odd), because...
2) The sample length and loop points are divided by two in the sample headers, meaning that if your sample is 10000 bytes long, you would write 5000 in the sample header.
3) The first two bytes of every sample should be 0, as that's how the samples with no loop are ended on the Amiga.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Zenon

Quote from: "Jojo"You might want to try adding 0x80 to all values before converting them to signed bytes, although I'm really sure if that would be of any help, but it's worth a try at least.
Some general hints:
1) The sample length MUST be even (add a zero byte if it's odd), because...
2) The sample length and loop points are divided by two in the sample headers, meaning that if your sample is 10000 bytes long, you would write 5000 in the sample header.
3) The first two bytes of every sample should be 0, as that's how the samples with no loop are ended on the Amiga.

Thank you, I found out the trick. :)

I think it's a kind of adpcm compression, it differs just a little respect delta
encoding used on xm

byte oldValue = reader.ReadByte();
           writer.Write(delta);

           for (uint i = 1; i < inputStream.Length; i++)
           {
               byte newValue = reader.ReadByte();
               delta += (newValue - oldValue);
               oldValue = newValue;
               writer.Write((sbyte)delta);
           }
Xrns2XMod converter
http://xrns2xmod.codeplex.com

Saga Musix

Once and forever: Module samples are normally not compressed, especially not with something as crappy as ADPCM - and the MOD format is no exception to that. The MOD format is so dead simple, that also applies to the samples - they are definitely not delta-encoded. However, if you try to load delta-encoded samples as "normal" signed samples, they still sound almost normal, but like they were played through a hipass filter. So you are definitely doing something wrong here. I'm not hiding any secrets from you here, it really is that simple, MODs use signed 8-bit samples.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.