pouët.net

Go to bottom

Ask pouet.net: .mod player with c/c++ source code?

category: code [glöplog]
Or more directly:

http://www.rockbox.org/tracker/task/5241

Actually, it looks like just identifying who wrote the original .mod player would help the project immensely. Somehow, they don't know whose code it is.
added on the 2007-12-08 07:51:06 by crusader crusader
I wonder if I should provide kb with a Kasten Bier.. will he revive OpenCP with a working win32-port and v2-support?
added on the 2008-10-26 21:24:34 by merkur merkur
Oh come on, the 1.5 release of V2 is perfectly capable of being plugged into whatever player architecture AND up since last Breakpoint.
added on the 2008-10-26 21:35:48 by kb_ kb_
i just hope it was not mikmod.
oh well, looking at post dates would be helpful... anyway, i still hope it was not mikmod.
The modplayer in Rockbox 3.0 is NOT MikMod, and MikMod still sucks _ASS_.

It does not handle 16 instrument soundtracker mods all that well, but protracker and noisetracker etc are handled well. And in most cases the 16 instrument soundtracker things play fine until they loop, whereupon they play too quickly.

Which makes 'Vote4me' sound very... well, Leinad on speed (:
Couple of bugfixes:

1/ note too high after an arpeggio :
Add
c.SetPeriod();
to line 519
before starting processing the effects

2/ not sure who is right there but line 655 I changed :
sF32 fac=sFPow(2.0f,sF32(rft)/(12.0f*16.0f));
to
sF32 fac=sFPow(2.0f,sF32(rft)/(6.0f*16.0f));
to have the same period table as OpenMPT.

BTW, thx, I'm using it for some mobile game soon to be released. I removed full paula emulation of course and switched everything to fixed point, works like a charm.
added on the 2010-06-18 12:18:12 by MsK` MsK`
Maybe someone can help me out a bit here!

I'm trying to port kb's Tinymod ported the PS3, but I'm having some problems.
At first I got no sound at all, but after some guessworking I think it depends on this code at line 124 and forward:

Code: todo: use a fake d/a table for this Cur.U32=((smp[Pos]^0x80)<<15)|0x40000000; Cur.F32-=3.0f;


Perhaps the union bit-fiddling-magic fails because this is a big-endian system or something, I don't know. Anyway, by replacing that with:
Code: Cur.F32=0.25+(smp[Pos]/512.0);

Code that is carefully pulled out of my ass and pure guessing since I don't have a clue on what's going on, at least I can hear the mod playing, and I can recognize the tune, but it doesn't sound right.

Any ideas on how to fix that?


Ideally I'd want to remove he Paula emulation entirely and just play the samples "straight up" to save CPU cycles, so if anyone has code for that, it would be much appreciated!
added on the 2011-01-23 18:28:43 by Sdw Sdw
OK, adding 0.25 in my "Cur.F32=0.25+(smp[Pos]/512.0);" was totally unnecessary, I get the same result without.
So what I have is simply a int->float conversion. Is that approximately what the old "magic" code did, or was there something else in it?
I still wonder if that is the only problem, or if there is some larger issue as
the replay works, but to me it sounds like it's playing with a sample rate of about 4kHz and lot of highfrequency hissing.

At least it seems to me like the replay part (running patterns etc.) is workign as it should, but the sample playback is somehow fucked.

Argh, this is why I have a problem with sound-coding - with graphics you can SEE what is wrong and know where to look for the problem, with sound it's more like "yeah, it sounds 'wrong' - what the hell do I do now?"

added on the 2011-01-24 10:41:47 by Sdw Sdw
You could sample it and load it into a sample editor, and see what is wrong? No idea on the code issue though.
added on the 2011-01-24 11:33:50 by psonice psonice
Sdw: That piece of code is a simple int->float conversion, yeah. You got it wrong tho: It converts the signed 8bit sample value into a float with the range -1..1.

In theory it should work correctly on all architectures that use IEEE floats regardless of endianess. What it does is the following:

- convert signed 8bit sample into unsigned with ^0x80
- shift left to fill the 23-bit IEEE float mantissa completely
- add an exponent of 0x40000000 (2.0) which makes the result a float value between 2 and 4
- subtract 3.0 to get it into the -1..1 range

Try the following: Cur.F32=(float)((int)(smp[Pos]^0x80)-0x80)/128.0; - that might do. Didn't test tho :)
added on the 2011-01-24 11:36:24 by kb_ kb_
Also if it still doesn't sould "clean" enough for you - that was the whole purpose of the paula sim. To get the "non interpolated at 3.5MHz" sound and these subtle ring modulation artifacts that come out of the cheap way Paula does volume :)
added on the 2011-01-24 11:39:08 by kb_ kb_
kb: Thanks, I'll give it a try when I get home.

And the not sounding clean part, that's not the Paula sims fault.
I tried the modules with you compiled Tinymod on my computer, and it sounds wonderful.
But my PS3 version really does sound like absolute shit, so something is amiss.
added on the 2011-01-24 12:04:34 by Sdw Sdw
sometimes i feel like i might actually be a real coder after all. then i read kb's explanations on sound code debugging and i quickly stumble back to reality.
added on the 2011-01-24 13:17:36 by psenough psenough
Thanks kb, the new snippet you posted worked like a charm, sounds great now!

added on the 2011-01-24 20:02:52 by Sdw Sdw
ps, that's trivia - just like some people can name a whole royal familiy and others have to look it up. the important fact is to know that it's there.
Wow, the Paula emulation is a serious CPU hog!
If my calculations are correct, playing a mod currently eats about 65% of the CPU time on my PS3...
Not surprising though, if I read the code correctly it goes through 512 samplepoints for each sample output.
I'm sure that the emulation code would be a prime candidate for moving to SPE-code, but that is a bit overkill for me, so I'm going to replace the Paula emulation with the "conventional mixing routines" that kb hints at in the sourcecode as if it something that any idiot should be able to do in five minutes.
After looking at the Paula code with ringbuffers, and "FIRs" and "slerps" and other gibberish, I haven't even figured out how to get started but once I do I'll probably be back with more stupid questions. ;)

added on the 2011-01-25 12:50:09 by Sdw Sdw
Here you go. A text-book mod-player mixer.
added on the 2011-01-25 12:56:22 by kusma kusma
kusma: Yeah, that was pretty straight-forward code, to me it looks like kind of "point-sampling" ie, take the closest matching sample and add it to the mix.

I thought that had to do some kind of interpolation/other magic with the surrounding samples.
added on the 2011-01-25 13:45:06 by Sdw Sdw
Nah, just point-sampling is usually sufficient. Some MOD-players support filtering (usually just linear, but some support sinc/lanczos and whatnot), but this tends to fuck up a lot of chip-tunes.
added on the 2011-01-25 13:53:02 by kusma kusma
Wohoo! I think I got it all figured out now, playback sounds alright (at least to my untrained ear) and now it eats less than 2% CPU.

Had a bit of a struggle finding out how to get those "period" values in the mod to map to my sample rate of 48kHz.
Lesson learned - when dealing with music, "that should be close enough" isn't right.
Yikes how bad and out of tune stuff sounded, eventhough I "thought" I had the correct rate (when I in reality was off by quite a few percent).
added on the 2011-01-25 23:31:34 by Sdw Sdw
This looks like a good place to ask : does someone has the sourcecode for a DS XM player ? I'm planning to use a custom XM format with ADPCM samples (or does XM supports ADPCM samples natively ?)
added on the 2011-01-26 01:18:32 by MsK` MsK`
kb,
Quote:
subtle ring modulation artifacts that come out of the cheap way Paula does volume


Not to derail the thread or anything, but could you please explain the details of this? I have not even noticed this artifact myself, and I want to know what really makes the Paula what it is :)
added on the 2011-01-26 02:13:35 by linde linde
MsK`: maxmod is open source and runs on the DS. But using ADPCM for samples is easier said than done; the DS hardware doesn't support looping them, for instance.
added on the 2011-01-26 17:26:01 by kusma kusma
I took a look at maxmod, seems really interesting, it even supports syncronisation events ! The thing is, I just tried to build a soundbank from an IT module, it gave me a file twice as big... 3MB big ! Since my musician isn't very familiar with tracking, I must help him not give him yet another problem to solve... Also, I took a look at the sourcecode, it's supposed to support ADPCM samples, but it must have never been finished : there is code, but first time I tried, mmutil crashed, and second time it outputed me "okay" and a soundbank of 0 bytes...

Are you sure you can't loop ADPCM samples ? I didn't tried yet but no$gba's documentation was saying this : "When using ADPCM and loops, set the loopstart position to the data part, rather than the header. At the loop end, the SAD value is reloaded to the loop start location, additionally index and pcm16 values are reloaded to the values that have originally appeared at that location. Do not change the ADPCM loop start position during playback."
The main problem I see is the 8 samples alignment thing...
added on the 2011-01-27 01:09:20 by MsK` MsK`

login

Go to top