Rockbox

Tasklist

FS#11945 - New HES (Hudson Entertainment System) sound codec ;)

Attached to Project: Rockbox
Opened by Mauricio Garrido (gama) - Tuesday, 15 February 2011, 20:55 GMT
Last edited by Andree Buschmann (Buschel) - Monday, 04 July 2011, 05:53 GMT
Task Type Patches
Category Codecs
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Hi, this is a new codec that plays HES music files. It is based on gme-0.5.2 by blargg http://slack.net/~ant/libs/audio.html

The patch was made from r29307

Features:

- 44Khz stereo sound.
- M3u Playlist support for additional metadata.
- Fade support.
- Subtrack selection using the seek function.
- Support adpcm samples.
- Based on the great game_music_emu library by blargg,
so you can expect nice sound quality.

Note 1: This version is for testing, if you find any bug please let me know.
Note 2: The codec uses the file open, read, seek functions that are only defined in
players that support recording, so we must find a solution for the players that
doesn't support that.

For a nice collection of HES music you can visit http://namida.com/kaminarimon/
This task depends upon

Closed by  Andree Buschmann (Buschel)
Monday, 04 July 2011, 05:53 GMT
Reason for closing:  Duplicate
Additional comments about closing:  Replaced by FS#12176.
Comment by JoshuaChang (JoshuaChang) - Wednesday, 16 February 2011, 05:37 GMT
i modified codec.c/h to make this patch work on non-recording device, but seems it failed to load hes-m3u?
Comment by Postolati Maxim (tails_) - Wednesday, 16 February 2011, 11:21 GMT
Done next to compile:
Got latest rockbox 29317 from SVN
Made directory "D2build" near rockbox folder then changed to it
Then "../rockbox/tools/configure" selected D2 normal build and then "make -j4" got this
http://pastebin.com/raw.php?i=SQK37KKk
What am i doing wrong again? or maybe some additional patches requed?

PS this all was made under cygwin with arm-elf-eabi-gcc (GCC) 4.4.4 and GNU ar (GNU Binutils) 2.20.1.20100303
Comment by Mauricio Garrido (gama) - Thursday, 17 February 2011, 03:02 GMT
The m3u playlist uses file open, read and close from the codec api, but those are only defined for
targets that supports recording, you can check that in the codecs.h file, i'm still looking how to solve that.

> i modified codec.c/h to make this patch work on non-recording device, but seems it failed to load hes-m3u?

That's strange, i have tested it on a sansa and on the uisimulator and it works fine. But the sansa supports
recording so the file api is already available. I guess i will try with another target in the simulator, could you please
paste your changes Joshua?

By the way, you can tell the m3u is loaded correctly because the codec will display additional info about
author, game and title and it will set the correct number of tracks. But t will not display the track title.
Comment by Postolati Maxim (tails_) - Thursday, 17 February 2011, 08:13 GMT
Then it loads correctly. Finally compiled updated gbs and hes codecs with joshuachang's fix ^^
btw i commented:
char * (*strrchr)(const char *s, int c);
int (*strcasecmp)(const char *, const char *);
in codecs.h and
strrchr,
strcasecmp,
in codecs.c because it caused some errors (this strings was doubled somewhere)

PS Switching track then loop enabled doesn't work like with nsf files (for both gbs and hes)
PPS Can you amplify pce's sound a bit?
Comment by Mauricio Garrido (gama) - Thursday, 17 February 2011, 15:23 GMT
I'm glad it worked now.

> Switching track then loop enabled doesn't work like with nsf files (for both gbs and hes)

Yes, i have to take a look at that. What should be the correct behavior?

> Can you amplify pce's sound a bit?

That is no problem, the volume gain value is located in the Hes_init function in hes_emu.c.
I reduced those values because it was a bit high compared to other formats like spc. But
i still have to find a good value for it.
Comment by Postolati Maxim (tails_) - Thursday, 17 February 2011, 16:01 GMT
Hmm correct behaviour was: next song acts as next sub-track previous track moves to the first sub-track and iirc if looping enabled it loops current track forever (i mean no fade out just like if it played in game).
I compared loudness to standard mp3s and it's much lower compared to them (SPC too but I didn't thought about editing source).

Sigh. why there are no external config files for codecs like in winamp? ~_~
PS is it real to get track title and length from m3u files or make them to work like CUEs?
Comment by Mauricio Garrido (gama) - Thursday, 17 February 2011, 22:07 GMT
> if looping enabled it loops current track forever

I believe you mean loop current sub-track not the whole file, right?

> is it real to get track title and length from m3u files or make them to work like CUEs

I guess that could be done but someone would have to change the main rockbox app to achieve that.
The track title can be obtained in the codec but rockbox takes around 15 seconds to update metadata changes,
so i decided to keep the game, artist and album info only. And even if track length is not displayed, it is used
internally by the codec.

And i also think that a codec config file like winamp's ini file would be nice. By the way i have finished a beta
of the atari SC68 plugin it is based on the sc68 library by Benjamin Gerard. There are some really nice
songs in his archive. Will upload the patch next week, though i'm not sure if anyone is interested in that format ;).
Comment by Postolati Maxim (tails_) - Friday, 18 February 2011, 02:31 GMT
oh 'coz I mean'd current sub-song

and.. will that sc68 plugin support sndh files? (original one was pretty buggy)
Comment by Mauricio Garrido (gama) - Friday, 18 February 2011, 03:08 GMT
> oh 'coz I mean'd current sub-song

Ok I don't think that would be difficult to do ;).

The sc68 codec supports both sc68 and sndh files, big sndh tunes (~450 Kb) are not supported yet, but i'm trying to fix that.
I have tested a lot of songs from the sc68.org archive and it seems they play fine.

By the way there are still some formats from game_music_emu that can be ported: kss (msx, sms),
ay, nsf, vgm (gg, sms, genesis) and maybe sgc (sms, gg).

I know there is already a nsf codec but i believe gme's nsf emu has better sound quality so it might be worth to make a new codec.
The ay emu would be easier to port but i haven't found any songs in that format.

And i'm not sure the kss and vgm codecs would work in rockbox, since they need a lot of cpu, but they may work without
the ym2413 chip (just maybe).


Comment by Postolati Maxim (tails_) - Friday, 18 February 2011, 04:50 GMT
well HES tunes with DAC used works fine on CPU with >80mHz frequency without they works fine even on 32mHz (at leat on D2 which uses ARM9). AY will be really nice :) (hmm is there tool to convert spectrum's tracker formats to ay?)
And does NSF emulation in blargg's supports vrc7 expansion?
And future idea: why not to use one path for same components? (blargg_common, blargg_config, m3u_playlist etc)
Comment by Mauricio Garrido (gama) - Monday, 07 March 2011, 15:24 GMT
Hi i just updated the patch, it contains minnor changes but
it should compile fine on all targets.

Changelog:
- Merged Joshua's patch to make the codec compile fine on all targets.
- Fixed some internal stuff.
- Increased sound gain (a bit).

Comment by Mauricio Garrido (gama) - Monday, 07 March 2011, 15:26 GMT
Oh again, the patch :|
Comment by Postolati Maxim (tails_) - Tuesday, 08 March 2011, 15:37 GMT
this one also based on latest blargg's library?
Comment by Mauricio Garrido (gama) - Wednesday, 09 March 2011, 03:46 GMT
Yes, partially, the most relevant change was the addition of the adpcm apu. But i will check if the cpu was
updated as well.
Comment by Postolati Maxim (tails_) - Wednesday, 09 March 2011, 06:28 GMT
Since what time PCE had ADPCM output? I remember only 5-bit wavetable synth and PCM DAC which can be used instead of one chanel (though wiki says that any chanel can be set to DAC mode)
Comment by Mauricio Garrido (gama) - Thursday, 10 March 2011, 02:41 GMT
It's in the wiki (http://en.wikipedia.org/wiki/TurboGrafx-16), in the PCEngine an ADPCM channel
was added, it is used by several HES rips especially for drums.
Comment by Postolati Maxim (tails_) - Thursday, 10 March 2011, 04:32 GMT
Oh that's for CD expansion :)
Comment by JoshuaChang (JoshuaChang) - Tuesday, 03 May 2011, 07:58 GMT
i've tried to make this work on new playback engine, here's the patch, sync against svn r29817:
NOTE: this is a very rough patch which contains some hacks in metadata stage, use at your own risk
Comment by Mauricio Garrido (gama) - Thursday, 12 May 2011, 01:27 GMT
Thanks, i am going to give it a try. But I guess it will be better if the extended m3u is read only once, just in the metadata parser.
And maybe subsongs info (remap and lengths) can be 'passed' to the codec through the ide3v2 buffer. Also i will try to remove the
Emu dependency from the m3u parser that way all the gme codecs could use the extended m3u support.

Anyway, the only codec that actually needs the extended m3u is the HES, since it doesn't contain an standarized metadata info. So for
now i removed the m3u support from the rest of the gme codecs and will upload the updated patches next week.

P.S. I have been working on a plugin based on the UADE (Unix Amiga Delitracker Emulator) library, it's working fine on the sansa, but i haven't
decided to upload if yet, maybe it would be better to do some private beta testing first. So if someone is interested please let me know :).
Comment by JoshuaChang (JoshuaChang) - Thursday, 12 May 2011, 02:00 GMT
well, the patch uploaded was very rough, it eats too much memory, i've made a modification to the hes_m3u.c and remove the dependency, will upload it ASAP, also, the multitrack sc68's length is wrong after modification, could you fix it?
Comment by Mauricio Garrido (gama) - Thursday, 12 May 2011, 03:32 GMT
> i've made a modification to the hes_m3u.c and remove the dependency,

Oh, that's nice ;).

> also, the multitrack sc68's length is wrong after modification, could you fix it?

Ok, will take a look at it.
Comment by JoshuaChang (JoshuaChang) - Sunday, 15 May 2011, 09:23 GMT
here's the patch,
when build all multi-track codecs(hes,nsf,gbs)with m3u support, the new patch only need additional 50k memory
compare to previous one, we have 350k memory saved!
Comment by Mauricio Garrido (gama) - Monday, 16 May 2011, 01:48 GMT
Thanks Joshua, i will try to pass the m3u data (at least the track's length and remap) to the codec through the id3 buffer,
.
Comment by Mauricio Garrido (gama) - Tuesday, 17 May 2011, 00:30 GMT
Hi, i have made some changes to your patch Joshua, could you try them?.

- Removed the Gme_emu structure dependency in the gme_m3u code,
- Store the entries data in the id3v2 buffer to make it available inside the codec.
- Stripped down the entry_t structure to hold only the track and length data, in order to reduce the size of the data
passed to the codec through the id3v2 buffer.
- Removed the m3u_playlist.c file from libhes since it is no longer needed and changed the m3u_playlist.h file to 'load' the m3u playlist
from the id3v2 buffer.
- Reduced the max m3u data to 16384 bytes, is there any hes m3u playlist bigger than that?

Can you help test this patch and tell me your thoughts about the changes?

P.S. I guess the strrchr and strcasecmp functions can now be removed from the codec structure as well.
Comment by JoshuaChang (JoshuaChang) - Tuesday, 17 May 2011, 00:42 GMT
i'll give it a try soon
ps: the biggest hes m3u as far as i know is Tokimeki Memorial.m3u, 12756 bytes
Comment by JoshuaChang (JoshuaChang) - Wednesday, 18 May 2011, 10:59 GMT
have tested the patch, only one question:
why use "ci->set_elapsed(t*1000)" instead of "ci->id3->elapsed = t*1000" in codecs/hes.c?
in this way, i can't change sub-track using 1 second skip length, the official nsf.c also has the same problem.
Comment by Mauricio Garrido (gama) - Wednesday, 18 May 2011, 21:49 GMT
> why use "ci->set_elapsed(t*1000)" instead of "ci->id3->elapsed = t*1000" in codecs/hes.c?

Well because i thought it was the correct way of doing it ;). I was just looking at some related bug,
the wps time doesn't get updated automatically with the new playback engine, when a subsong changes it stays in zero,
but if i skip forward to manually change subsong it starts to work fine. Looking at the playback.c file it has to do something
with the pcm latency (see playback.c ~ void audio_codec_update_elapsed(unsigned long value)), but i don't understand quite well
that part.

Unfortunately, setting ci->id3->elapsed directly doesn't help either 8(.

BTW, i have updated the other codecs as well, will upload them ASAP. Also i finished porting the AY and SGC codecs too ;).
Comment by JoshuaChang (JoshuaChang) - Thursday, 19 May 2011, 00:05 GMT
i don't know if you use settings->playback settings->skip length->1s to make it easier to change subtrack, but when using "ci->set_elapsed(t*1000)" in the code, i couldn't change subtrack anymore
Comment by Mauricio Garrido (gama) - Thursday, 19 May 2011, 00:30 GMT
> i don't know if you use settings->playback settings->skip length->1s ...

Mmm, no i don't use that option. Some findings, if i use ci->set_elapsed() the WPS time gets updated until subtrack 3 is reached,
and the reason for this is that the function audio_codec_update_elapsed(unsigned long value) rejects the value if it is lower than the pcm buffer latency,
in the sansa fuze the 'latency' is around 2500.

If i use ci->id3->elapsed directly, it is easier to change subtrack but the WPS time doesn't get updated at all, and i haven't been able
to find the reason for this. Hope some dev can help us with this ;).
Comment by JoshuaChang (JoshuaChang) - Wednesday, 25 May 2011, 15:20 GMT
the new 0.5a patch has a small issue, it couldn't play $00 track in m3u, here's the fix, put it in the libhes dir.
   hes_emu.c (22.3 KiB)
Comment by Mauricio Garrido (gama) - Thursday, 09 June 2011, 23:13 GMT
Thanks again Joshua, i have merged your changes and made a couple of code cleaning,
but there is still pending the elapsed time issue. Here is the latest full patch:


Loading...