arnaud-neny / rePlayer

another multi-formats music player
Other
55 stars 4 forks source link

C Question #15

Open melony-cmd opened 7 months ago

melony-cmd commented 7 months ago

I just got done doing Arnaud Carré YM SDK, which required I build the .lib into a .dll for PureBasic project on my travels I found this gem of a player.

I've noted the replays, all have a C++ interface which is really difficult for me to write and much more so for PureBasic to interface with standard C no issue.

Is there any chance we/I could add a C interface?

I've noted there is one function exposed during a library examination of the output dll binary, getReplay?? I forget it's name would this be a good place where ever getReplay?? Is to add additional functionality to call the replay library to output PCM data?

Ideally I'd like to add functions; Play Pause Stop Load LoadMemory GeneratePCM

Maybe better ways than these 2 net idea is gaining data for vumeters. GetChannel (stereo/mono) GetChannelTrack (stereo/mono), (channel)

Might be better at this rate to just replace rePlayer with DLL c/c++ interface might be faster.

arnaud-neny commented 7 months ago

Making a lib/dll of the player shouldn't be that hard, just need to find some time to do it.

melony-cmd commented 7 months ago

Making a lib/dll of the player shouldn't be that hard, just need to find some time to do it.

I'd like to hope so :) I've had a we stab at it myself but my C++ skills (bad!), my C skills which I'm more formular with, it's more difficult still when you're not the author of the code in the first place. Truth be told I don't actually program in C (insert type) I can work with some variants however I'm more at home with Pure Basic it unfortunately has it's short comings and strengths too that said, the negatives in this regard is it cannot access a DLL that needs to be address in a OOP type style, but no problems with a C type style.

Take for example; ST Sound Library we had that up and running in a couple of days because all I needed to do was state; extern "C" __declspec(dllexport) YMMUSIC * YM_Init(); in a DLL, and write some short Pure Basic code to call them and done.

I had hoped to do similar with rePlayer; when I found. extern "C" __declspec(dllexport) rePlayer::ReplayPlugin* getReplayPlugin()

I thought great all I need to do is extern "C" the missing functions to make this play audio or give me the PCM data to play it though waveOut and we're golden, aside from digging though the code to find vumeter information.

I backed off at the point when I saw imGui() calls in the replays (plugins) because I felt the system was more integrated than I first initially thought, which was that the replays and the UI where separate like church and state, which is where I stopped.

To close this reply: I'd be most grateful if you could see you way to have sometime to make an addition so the replays can be accessed from C, thanks for your time reading.

melony-cmd commented 7 months ago

Managed to get this far ReplayDLL.h of course I could be doing this all the wrong way, got a major issue with getting the Render(er) function.

`// namespace rePlayer namespace rePlayer { extern ReplayPlugin g_replayPlugin; }

extern "C" __declspec(dllexport) rePlayer::ReplayPlugin* getReplayPlugin() { return &rePlayer::g_replayPlugin; }

extern "C" __declspec(dllexport) rePlayer::ReplayPlugin Init(core::SharedContexts ctx,core::Window & window) { rePlayer::g_replayPlugin.init(ctx, window); return 0; }

extern "C" __declspec(dllexport) rePlayer::ReplayPlugin* Release() { rePlayer::g_replayPlugin.release(); return 0; }

extern "C" __declspec(dllexport) rePlayer::ReplayPlugin Load(core::io::Stream stream,core::CommandBuffer metadata) { rePlayer::g_replayPlugin.load(stream,metadata); return 0; }`

arnaud-neny commented 7 months ago

this is not going to work well as the dll are not standalone, they are extensions to replayer and they use it's data. Loading and using it directly is not going to work properly (or at all).

melony-cmd commented 7 months ago

Yeah, I didn't think so myself to be honest I hadn't yet even tried to call any of them yet as the linch pin was 'Render' and until that was a thing I wasn't even going to try, but thanks for confirming my concerns that the replays where (for want of a better phrase please forgive) mangled with the GUI code. I do often wonder why with all these retro file formats developers try to re-invent a WinAmp clone each and every time, rather than just making a universal interface for them all that can be used by all languages and then make all UI they like.

In my case I'm just trying to extend Pure Basic file format knowledge base, on the plus side the replays are good something at least the original source code seems to be intact, that can be pulled out and used else where, much like I did with SNDH.