| |
Mindcooler
Registered: Nov 2006 Posts: 28 |
ReSID DLL interface?
Is there any documentation for the interface for the ReSID/ReSIDFP DLL (thought of using LibReSIDFP.dll from the XSID project), or are there any other docs that can help figuring out how to use it? Or is it a case of RTFC? |
|
| |
Mixer
Registered: Apr 2008 Posts: 447 |
Initialize
repeat:
- write values to emulated sid
- run the emulated sid and receive a chunk of audio data
- play audio out |
| |
Mindcooler
Registered: Nov 2006 Posts: 28 |
Yes, I have used the HardSID interface before, so I guess it will be pretty similar, but the HS interface was documented so you could know what parameters to put where. And I guess ReSID is cycle accurate and would be timed/synced with the "real world" in a different way? Like, do you tell out how many cycles to emulate and get out a piece of sound data, or the other way around? |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
You the source Luke.
Download: https://sourceforge.net/projects/sidplay-residfp/files/libsidpl..
Take a log at sidplayfp.h, it's well documented:
"/**
* Run the emulation and produce samples to play if a buffer is given.
*
* @param buffer pointer to the buffer to fill with samples.
* @param count the size of the buffer measured in 16 bit samples
* or 0 if no output is needed (e.g. Hardsid)
* @return the number of produced samples. If less than requested
* and #isPlaying() is true an error occurred, use #error() to get
* a detailed message.
*/" |
| |
Mixer
Registered: Apr 2008 Posts: 447 |
Also, the samplerate and sid clockspeed are given in the initialization parameters. Resid output is resampled to given samplerate, so set it to your audio output rate, and the emulation is realworld synced. |
| |
Mindcooler
Registered: Nov 2006 Posts: 28 |
That doesn't look like the interface of the dll I've got:
ReSIDClock
ReSIDClockSilent
ReSIDCreate
ReSIDDestroy
ReSIDEnableFilter
ReSIDInput
ReSIDSetChipModel
ReSIDSetFilter6581Curve
ReSIDSetFilter8580Curve
ReSIDSetSamplingParameters
ReSIDWrite
Is there a official dll built somewhere? |
| |
Mindcooler
Registered: Nov 2006 Posts: 28 |
I found the wrapper functions for the XSID DLL, so I guess I can follow the money down the rabbit hole:
https://github.com/M3wP/XSID/blob/master/ReSIDFP/LibReSIDFP.cpp |
| |
Mixer
Registered: Apr 2008 Posts: 447 |
Go for it!
I looked at the resid code included in Vice, Goattracker, libsidplay and pyresid. They all have slightly different wrappers for the engine but operate in the same way. I assume that the XSID ReSIDClock() works just like the GT resid clock() one or equivalent gen() in the pyresid. |
| |
Mindcooler
Registered: Nov 2006 Posts: 28 |
I got a 6581 running, but I don't get any output from an 8580. I don't get what the difference is; it seems that I need to clock the 8580 for each write I do? What gives?
void SID::write(int offset, unsigned char value)
{
busValue = value;
busValueTtl = modelTTL;
if (model == MOS8580)
{
delayedOffset = offset;
delayedValue = value;
}
else
{
writeImmediate(offset, value);
}
} |
| |
Krill
Registered: Apr 2002 Posts: 2969 |
You're trying to write multiple SID registers in the same clock cycle? |
| |
Mindcooler
Registered: Nov 2006 Posts: 28 |
Yes, that works fine for 6581. I'd like to keep all time management in the sound driver, not the data write routines. I'm not trying to emulate a c64. |
| |
Krill
Registered: Apr 2002 Posts: 2969 |
I... i don't even |
| |
Mindcooler
Registered: Nov 2006 Posts: 28 |
I'm not sure what's so strange. Is it illegal to break the laws of physics in an emulated device?
Writes are made asynchronously. And the time is stepped in chunks. |
| |
Krill
Registered: Apr 2002 Posts: 2969 |
You might not want to emulate a C-64, but i take it you want to emulate a SID... AND expect the emulation to be faithful?
Then really, you cannot violate its fundamental hardware principles, emulated or not. No more than one read or write per clock cycle (yes, synchronous), as there are latches and whatnot in its internal state machine.
6581 might look like it's working with that horrible hack, but i'm pretty sure some things are quite distorted compared to the real chip.
What's so problematic about spreading out your writes over several clock cycles? |
| |
Mindcooler
Registered: Nov 2006 Posts: 28 |
That would entail making a queue and screwing around in the driver routine, and I'm lazy :)
But I guess it's doable. Although a 6581 is alright, a 8580 is more synthy and more suitable for my purpose. |
| |
Krill
Registered: Apr 2002 Posts: 2969 |
Yeah, and about the asynchronous writes... Do you mean you called the set-register function asynchronously, from another thread than the one running the actual emulation? If you do that, make sure you have your synchronisation primitives under control. :) |
| |
Mindcooler
Registered: Nov 2006 Posts: 28 |
Yeah, that wasn't a problem with other emulators/synths I have used in the past. Perhaps it would be a problem with resid(-fp), didn't investigate the code to figure that out. Right now it's a moot point. Just bring in an SPSC queue, put things in one end asynchronously and write them to the SID in the driver. No locking needed. |
| |
Krill
Registered: Apr 2002 Posts: 2969 |
The synchronisation will then probably be encapsulated within and implemented by the SPSC queue.
Perhaps you should also take some care about the write order of SID registers, as that can make quite some difference. |