Jump to content

linux asid player


aTc
 Share

Recommended Posts

After getting annoyed with asidxp, and having to boot into windows to actually use it, I decided to have a go at getting the linux sidplay2 to output to midi.

And so after a few days of messing about (most of which was listening to sids on my sammich), I came up with this:

http://wreck.k-n-p.org/asid/sidplay2-asid.tar.bz2

It's a sidplay2 with the hardsid part modified to output to midi.

It works for most sids, there are a few problems with some that write to the registers more than 3 times every frame, since the protocol doesn't support that.

Sample playback obviously also doesn't work.

It's pretty much a hack, the code needs some serious cleaning up, and needs to be moved into its own builder, instead of hijacking the hardsid one.

It also uses a very basic, slightly inaccurate timing method at the moment, which also needs work.

I'll get to that once i've tried all 38,714 sids in the hvsc with it, which is slightly more fun :)

It's pretty much hardcoded to work with linux+alsa at the moment, but since it uses RtMidi to take care of the midi end of things, it should have no problems running on other platforms after some cleaning up.

No binaries, you'll have to compile this yourself. See readme.txt included in the archive for compiling details.

Tested on ubuntu 10.04, both 32 and 64 bit versions, and crosscompiled to arm.

It's pretty much in the "it works for me" stage now, any suggestions, bugfixes and code cleanups are welcome :)

Link to comment
Share on other sites

Nice work, your implementation looks less dirty than my own one :)

(some years ago I hacked the code directly into resid-builder, and MIDI data was output to /dev/midi)

For writing into the waveform registers I'm using a different strategy, here an excerpt:


// TK: this probably doesn't match with the way how the original ASID software handles the second
// waveform register set - but I find it useful this way
// strategy: whenever the two sets are allocated, shift the 2nd one to the first entry...
// this ensures, that the two last waveform changes take place

// write to waveform register? check if first set is already allocated
if( mapped_addr >= 0x16 && mapped_addr <= 0x18 && asid_reg[mapped_addr] & 0x100 ) {
// switch to second waveform register set
mapped_addr += 3;

// if this one is allocated as well, copy the old one to the first set
if( asid_reg[mapped_addr] & 0x100 )
asid_reg[mapped_addr-3] = asid_reg[mapped_addr];
}
[/code]

Here the code of an overworked version if you would like to compare the methods (but it's for the MacOS based SidPlay)

http://www.ucapps.de/tmp/asid/ASID_MIDI.m

Best Regards, Thorsten.

Link to comment
Share on other sites

Hi guys,

My first post :-) I'd just like to say thanks for providing what proves to be the best and most stable way of playing back SID audio files for me. I'm using 32 bit Ubuntu 10.04 and an Edirol UA-101 audio interface, along with TK/Wilba's super-duper, amazing, formidable, (insert your favourite superlative here) MB-6582.

Much respect to all you hard working fellows!

JC

Currently rocking out to Jazzcat by DRAX - Awesome!

Link to comment
Share on other sites

Making it more stable than asidxp isn't much of a challenge :)

And as a bonus, here's a video of the player running on an arm device.

Apart from the obvious timing problems, it's quite easy to get it running on almost any device that runs linux.

(and has a midi port).

Fixing the timing properly is a bit of a challenge though, and I first have to dig about in the sidplay2 source a bit more to find out exactly how it does things.

Link to comment
Share on other sites

An extravagant demo! ;)

Do you notice the same timing accuracy issues on a fast computer as well?

My approach was to add a hook into the resid emulation, so that the emulated SID + the real SID can be played in parallel. This was the easiest way to compare the timings, but also the differences between original and emulation.

Best Regards, Thorsten.

Link to comment
Share on other sites

Problem with my version is that it just puts the task to sleep based on the c64 clock cycles between the writes, without taking into consideration how long the emulation, or the midi writing takes.

So on a fast computer it's more accurate, since it spends less time calculating stuff.

It's mostly to do with the timer used by the kernel for task switching. I think the main reason for the slowdown is because my desktop is using a 1ms timer, and the arm device as 10ms one.

(sid playing in that video is C64Music/MUSICIANS/W/Whittaker_David/Tube.sid , should have probably used a more well known tune)

A more accurate method would be one where you just have a function that's called 50 times/second, and sends the changes. But i think you run into problems with sids that were meant to run at 60hz, or use timing other than vblank. At the moment I have no idea if it's possible to get that sort of info from sidplay2 inside a builder.

All you seem to get in a builder is which register is written to, and at which clockcycle, and for that method to work properly you really need to be able to call the emulation for new data, instead of the emulation calling you when something's written to a sid register.

As I said before, really need to dig a lot deeper into this whole thing.

Link to comment
Share on other sites

I've been listening to some of my favourite classics (Tel, Hubbard, Dunn, DRAX, Linus, Jeff etc) and have only just discovered and been blown away by 'Hot Mommas' by Jammer (C64Music/MUSICIANS/J/Jammer/Hot_Mommas.sid) - it's amazing what the SID is capable of! I also never realised TK had been composing tunes that are in the HVSC. Kudos TK!

Link to comment
Share on other sites

Turned out there was an easier solution, which is clock_nanosleep(), which will wake your task up at a requested time with pretty good accuracy.

Videos of it playing various sids on the pandora here.

Video 2 uses nanosleep instead of usleep, which already improved accuracy quite a lot, but it still wobbled about a bit.

Video 3 uses clock_nanosleep, waking it up at a requested time, and is far more stable. Has only minor problems when there's other programs generating a heavy cpu load, but that's more a task switching priority thing.

Accuracy can be improved even more by giving the task a higher priority.

sidplay2-asid_0.2 can be downloaded here.

I'll have a look at the VICE code, but i'm not promising anything :)

Link to comment
Share on other sites

Well, best player.. I only show the sids that work properly in the videos :)

And it's basically as good as sidplay2 is.

Of course the biggest problem is the asid protocol itself.

Anyway, I did mess about with VICE, and to my own surprise managed to get it to output to asid.

It's in very early stages, but it works reasonably well.

And as before, the biggest limitation is the asid protocol, you have to wait untill there haven't been any writes to the sid registers for a while, then group all the writes together and send the data.

Would be a lot easier if you could just send the register and data in two midi bytes and have it update immediately.

No idea if midi can handle that sort of stuff fast enough, they must have had a reason to make asid the way it is.

Here's a video of that hacked VICE, playing Great Giana Sisters.

Link to comment
Share on other sites

Would be a lot easier if you could just send the register and data in two midi bytes and have it update immediately.

No idea if midi can handle that sort of stuff fast enough, they must have had a reason to make asid the way it is.

The transfer of 2 bytes takes 0.64 mS, you would hear a difference if for example the gate flags of the 3 waveform registers would be set one after another with such a delay.

Try the "oscillator phase" parameter of the MBSID lead engine, then you known what I mean ;)

Best Regards, Thorsten.

Link to comment
Share on other sites

Oweeeeeee, you have a Pandora! My GP2x gave up on me about 6 months ago :hmm: Does this mean you might be hacking the VICE code to allow playing SID music through the Midibox SID? (Hint, Hint :wink:)

Done. :)

Well, not quite, needs a lot of cleaning up first, and better integration with the rest of vice, but it's usably on my machine.

Link to comment
Share on other sites

That is a whole lot of Cool! Will you be releasing your modifications to the VICE code and/or submitting the changes to the VICE team? I sure hope so..... It is a shame there is no way to pump SID samples via MIDI.... Turbo Outrun anyone? Some may see playing SID files as belittling the capabilities of the MB-SID but I for one would love the ability to use the MB-SID as the sound hardware for C64 demos, trackers, games etc as well as using it as a mighty professional synthesiser. I have only just finished building the base board of my MB6582 and have still to source parts for the control surface - I feel like I am on the cusp of attaining true chiptune nirvana (with lots of help of course!) :D

Edited by toadstool
Link to comment
Share on other sites

Ah, yes, I seem to have forgotten to move the old writes to the secondary registers back to the first ones.

Fixed now.

Do you happen to have a list of sids that are especially problematic to play back ?

I could contribute to the that list i'm pretty sure! :thumbsup:

*cough* subtune 2 *cough*

Well done on getting Commando to play properly, asidxp and nils hacked .dll couldn't play it properly.

Edit: Asid XP plays it fine actually.

Dude what the hell is the name of the sid at the start of video 3 with the speech?

Does this mean you were able to support PCM playback for that sid?

Or is using some other tricks like Ring Mod to generate the speech.

Edited by Smithy
Link to comment
Share on other sites

Well done on getting Commando to play properly, asidxp and nils hacked .dll couldn't play it properly.

Edit: Asid XP plays it fine actually.

If ASID XP plays it properly then my version will play it properly as well, if you set the flush mode to ASID XP ;)

Link to comment
Share on other sites

Dude what the hell is the name of the sid at the start of video 3 with the speech?

Does this mean you were able to support PCM playback for that sid?

Or is using some other tricks like Ring Mod to generate the speech

I think you are referring to 'Hot_Mommas' by 'Jammer' (see my reply #11 above) and I believe it uses some clever ring modulation and possibly changing filters. No PCM samples at all at all. It is totally awesome though eh!? I love it. I tried playing that particular tune back through ASID XP and then muted each channel in turn and it seems one of the channels controls the shape of an oscillator on another channel. Or something.

Link to comment
Share on other sites

If ASID XP plays it properly then my version will play it properly as well, if you set the flush mode to ASID XP ;)

How do you set the flush mode to ASID XP?

I'm forced to use version 0.1 of your dll, as the the newer version tries to blow up my processor!

Edited by Smithy
Link to comment
Share on other sites

I think you are referring to 'Hot_Mommas' by 'Jammer' (see my reply #11 above) and I believe it uses some clever ring modulation and possibly changing filters. No PCM samples at all at all. It is totally awesome though eh!? I love it. I tried playing that particular tune back through ASID XP and then muted each channel in turn and it seems one of the channels controls the shape of an oscillator on another channel. Or something.

Thanks a lot for the reply, i really appreciate it!

I think a skipped over a lot of posts just to get to the videos, hehe!

Edit:

Check out this gem of a thread on non-pcm c64 speech synthesis:

http://noname.c64.org/csdb/forums/?roomid=14&topicid=17568&showallposts=1

Edited by Smithy
Link to comment
Share on other sites

I'll try to get it cleanly into VICE as just another sound output option. VICE is pretty modular.

Of course I have to fix a lot of stuff first.

PCM playback is never going to work with this protocol, and even with another protocol there's still an awful lot of data to be sent over midi.

Most routines seem to write every 120-200 clockcycles to register $18.

And most sids that don't play back properly now is because it writes more than once to a register, which the protocol doesn't support (except for two writes to the gate registers).

And another possible problem might be that the delay between the writes to the registers is lost as well.

Link to comment
Share on other sites

Thanks a lot for the reply, i really appreciate it!

I think a skipped over a lot of posts just to get to the videos, hehe!

Edit:

Check out this gem of a thread on non-pcm c64 speech synthesis:

http://noname.c64.org/csdb/forums/?roomid=14&topicid=17568&showallposts=1

Great link.....and the man himself explains it in the last post. It is oscillator sync and not ring-mod..... clever stuff indeed.

Link to comment
Share on other sites

I'll try to get it cleanly into VICE as just another sound output option. VICE is pretty modular.

Of course I have to fix a lot of stuff first.

PCM playback is never going to work with this protocol, and even with another protocol there's still an awful lot of data to be sent over midi.

Most routines seem to write every 120-200 clockcycles to register $18.

And most sids that don't play back properly now is because it writes more than once to a register, which the protocol doesn't support (except for two writes to the gate registers).

And another possible problem might be that the delay between the writes to the registers is lost as well.

PCM playback was more than wishful thinking on my behalf.......

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...