0
0

Hi!
I like to use a plugin which I got for winamp. It’s the TFMX file format (very old, I know ^^) and I like to play it in my own applications.

The problem is I don’t know how to use Streams, DLLs and so on and I don’t know how to start. Is there maybe an example project somewhere?

(The TFMX Files doesn’t have an end)

  • You must to post comments
0
0

I’m just figuring out how the input structure of winamp works.

A small problem i’ve found is that the In_Module structure of winamp also can control the Out_Module and the DSP and VIS modules.

And this is the function:
// returns number of samples to output. This can be as much as twice numsamples.
// be sure to allocate enough buffer for samples, then.
int (*dsp_dosamples)(short int *samples, int numsamples, int bps, int nch, int srate);

First try to understand loading and unloading winamp modules.
[url:2nvkrte8]http://www.fmod.org/forum/viewtopic.php?t=1621[/url:2nvkrte8]

Also get the in_minisdk from winamp.
http://www.winamp.com/nsdn/winamp2x/dev … s/in.jhtml

Then your halfway there (like me)

Now someone needs to figure out how to use the “dsp_dosamples”

  • You must to post comments
0
0

Hmm it seems we need to fake a outmodule and the intern vis commands to get it working.
That’s my opinion after reading the IN_RAW.C example in the in_minisdk of winamp, which contains:
[code:1t7fvkae]mod.SAAddPCMData((char )sample_buffer,NCH,BPS,decode_pos_ms);
mod.VSAAddPCMData((char *)sample_buffer,NCH,BPS,decode_pos_ms);
decode_pos_ms+=(576
1000)/SAMPLERATE;
if (mod.dsp_isactive()) l=mod.dsp_dosamples((short )sample_buffer,l/NCH/(BPS/8),BPS,NCH,SAMPLERATE)(NCH*(BPS/8));
mod.outMod->Write(sample_buffer,l);[/code:1t7fvkae]

In the DecodeThread 😥

  • You must to post comments
0
0

Yeah.
I had the same idea in mind but, unfortunately, it seems a bit too difficult. I just gave a look to header files some time ago, but they were messy I couldn’t understand almost anything :(
However, if you find the way to emulate winamp you’ve almost there because decoded streams coming from the winamp plugin can be reversed into fmod output simply using a dsp callback.

  • You must to post comments
0
0

Ok i mailed karlkox and he had some usefull tips to start with.
I’ll go check it out and try to implement it 😀

  • You must to post comments
0
0

OK i made some code but know i need to know how to create a FMOD buffer and place the data in that FMOD buffer.

The OutModule->OutWrite function gets the buffer from the input plugin if OutCanWrite >= ((576NCH(BPS/8))<<(mod.dsp_isactive()?1:0))
as shown in the IN_RAW.C example of the winamp in_minisdk

[code:2vgws6ec]#include "in2.h" // the Winamp Input header file
typedef In_Module* (*pGetInModule)();
HMODULE wa_IN;
In_Module *InModule;
Out_Module *OutModule;[/code:2vgws6ec]

[code:2vgws6ec]/********** Input Plugin functions **********/
void SetInfo( int bitrate, int srate, int stereo, int synched ) {
// here you can specify various infos
}

void SAAddPCMData( void PCMData, int nch, int bps, int timestamp ) { / not needed */ }

int SAGetMode() {
return 1; /* must return 1 to say ok */
}

void SAAdd( void data, int timestamp, int csa) { / not needed */ }

void VSAAddPCMData( void PCMData, int nch, int bps, int timestamp ) { / not needed */ }

int VSAGetMode( int specNch, int *waveNch ) {
return 0; /
returning 0 mean, no pb */
}

void VSAAdd( void data, int timestamp ) { / not needed */ }

void VSASetInfo(int nch, int srate) { /* not needed */ }
int dsp_isactive() {
return 0; }

int dsp_dosamples( short int *samples, int numsamples, int bps, int nch, int srate ) {
return 0; }

void EQSet( int on, char data[10], int preamp) { /* not needed */ }

void _SAVSADeInit() { /* not needed */ }

void WMIN_SAVSAInit( int maxlatency_in_ms, int srate ) { /* not needed */ }[/code:2vgws6ec]

[code:2vgws6ec]/********** Output Plugin functions **********/
void OutConfig(HWND hwnd) { /* not needed */ }

void OutAbout(HWND hwnd) { /* not needed */ }

void OutInit() { /* not needed */ }

void OutQuit() { /* not needed */ }

int OutOpen(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms)
{
// here you will set yout internal variables
// (samplerate, numchannels ...) to the one specified in the params
return 0;
}

void OutClose() { /* close it */ }

int OutWrite(char *buf, int len)
{
// here you will write your data to the *buf param,
// it must be fast and efficient
return 0;
}

int OutCanWrite()
{
// return the current buffersize (the one allocated by fmod for example)
return last_pause?0:1610241024;
}

int OutIsPlaying()
{
// non0 if output is still going or if data in buffers waiting to be
// written (i.e. closing while IsPlaying() returns 1 would truncate the song /*
return 0;
}

int OutPause(int pause)
{
int last_pause = 0;
int t=last_pause;
last_pause=pause;
// return previous pause state
return t;
}

void OutSetVolume(int volume)
{
// filled by the in_***
}

void OutSetPan(int pan)
{
// filled by the in_**
}

void OutFlush(int t)
{
// flushes buffers and restarts output at time t (in ms)
}

int OutGetOutputTime() { return 0; /* not needed ? */ }

int OutGetWrittenTime()
{
// wa_in uses this in a calculation to get exact: getoutputtime()
return 0;
}[/code:2vgws6ec]

[code:2vgws6ec]void __fastcall Step1Click(TObject *Sender)
{
OutModule->version = 0;
OutModule->description = “FMOD Out Plugin emulator”;
OutModule->id = 33;
OutModule->Config = OutConfig;
OutModule->About = OutAbout;
OutModule->Init = OutInit;
OutModule->Quit = OutQuit;
OutModule->Open = OutOpen;
OutModule->Close = OutClose;
OutModule->Write = OutWrite;
OutModule->CanWrite = OutCanWrite;
OutModule->IsPlaying = OutIsPlaying;
OutModule->Pause = OutPause;
OutModule->SetVolume = OutSetVolume;
OutModule->SetPan = OutSetPan;
OutModule->Flush = OutFlush;
OutModule->GetOutputTime = OutGetOutputTime;
OutModule->GetWrittenTime = OutGetWrittenTime;
}
//—————————————————————————
void __fastcall Step2Click(TObject *Sender)
{
if (wa_IN == NULL) {
wa_IN = LoadLibrary(“in_mp3.dll”); // Load a winamp Input plugin
if (wa_IN != NULL) {
// Now get the Process Address
pGetInModule GetInModule = (pGetInModule) GetProcAddress(wa_IN, “winampGetInModule2”);
// Now get the module of the plugin
InModule = GetInModule();
GetInModule = NULL;
if (InModule != NULL) {
InModule->hMainWindow = Application->Handle; // The handle of the mainwindow
InModule->hDllInstance = wa_IN; // Handle to this DLL
InModule->Init(); // Initialize the module
GroupBox1->Caption = InModule->description;

InModule->SetInfo = SetInfo;
InModule->SAAddPCMData = SAAddPCMData;
InModule->SAGetMode = SAGetMode;
InModule->SAAdd = SAAdd;
InModule->VSAAddPCMData = VSAAddPCMData;
InModule->VSAGetMode = VSAGetMode;
InModule->VSAAdd = VSAAdd;
InModule->VSASetInfo = VSASetInfo;
InModule->dsp_isactive = dsp_isactive;
InModule->dsp_dosamples = dsp_dosamples;
InModule->EQSet = EQSet;
InModule->SAVSADeInit = _SAVSADeInit;
InModule->SAVSAInit = WMIN_SAVSAInit;
InModule->outMod = OutModule;
}
}
}
}
//—————————————————————————
void __fastcall CloseClick(TObject *Sender)
{
if (wa_IN != NULL) {
if (InModule != NULL) {
InModule->hMainWindow = NULL;
InModule->hDllInstance = NULL;
InModule->Quit();
}
FreeLibrary(wa_IN);
wa_IN = NULL;
}
}[/code:2vgws6ec]

  • You must to post comments
0
0

Hmmm i got little ferther:

[code:tmeti226]signed char streamcallbackWrapper(FSOUND_STREAM *stream, void *buff, int len, int param) {
// Must i move the winamp char *buf here to void *buff ???????
return 1;
}

signed char F_CALLBACKAPI endcallback(FSOUND_STREAM *stream, void *buff, int len, int param)
{
// What must i do here ?????
return TRUE;
}

int OutOpen(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms)
{
srate = samplerate; // 44100 hz
numchan = numchannels; // 2 = stereo 1= mono
bps = bitspersamp; // 16 bit or 8 bit
int length = 576numchan(bps/8)*2;
fStream = FSOUND_Stream_Create(streamcallbackWrapper, length, FSOUND_NORMAL, srate, 12345);
FSOUND_Stream_SetEndCallback(fStream, endcallback, 0);
return 0;
}[/code:tmeti226]

I also know that the input plugin first asks if it CanWrite() before Write();

Hé i’m not a genius in programming so please HELP!
Now i’m really stuck. 😥

  • You must to post comments
0
0

OK moved the “Almost solution” to a new topic.

[url:1h3sa7x5]http://www.fmod.org/forum/viewtopic.php?t=1683[/url:1h3sa7x5]

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.