Creating a SidPlay DLL

Help
Damien
2007-01-08
2013-05-02
  • Damien

    Damien - 2007-01-08

    Hi Guys,

    I've hit another problem creating a SisPlayer I can use from C#. At the moment I am trying to create a DLL that I can use in my C# programs utilising Pinvoke. The DLL I have created contains some static functions to allow me to play sid files. I am having problems getting the DLL to build. Each time I receive a linker error:

    SidplayDLL error LNK2019: unresolved external symbol "public: __thiscall Audio_DirectX::Audio_DirectX(void)" (??0Audio_DirectX@@QAE@XZ) referenced in function "void __stdcall PlaySidFile(void)" (?PlaySidFile@@YGXXZ)

    This implies that I am not linking to a required lib - however, I am linking to exactly the same libs I used when i successfully built a .exe test yesterday which successfully played a sid file. I cannot see from the above error any indication of which lib file I require. Does anyone have any ideas.....?

    My code is as follows:

    #include "stdafx.h"
    #include "mmsystem.h"
    #include "sidplay2.h"
    #include "resid.h"
    #include "sidtune.h"
    #include "directx.h"
    //#include "audiobase.h"
    #include "AudioConfig.h"

    #include <iostream>

    //using namespace std;
    const char* szSidFile = "C:\\One.sid";
    void* pBuffer = 0;

    void __stdcall PlaySidFile()
    {   
        // Setup audio driver
        AudioDriver *pAudioDriver = new AudioDriver;
       

        AudioConfig* pAudioConfig = new AudioConfig;
        pAudioConfig->bufSize = 22000;
        pAudioConfig->frequency = 44100;
        pAudioConfig->precision = 16;
        pAudioConfig->channels = 2;
        pBuffer = pAudioDriver->open(*pAudioConfig, szSidFile);
       
        SidTune* pTune = new SidTune(szSidFile, 0, false);

        // Select the song to play within the sid file
        pTune->selectSong(0);

        // Configure the sidplay2 object
        sidplay2* pSidplay2 = new sidplay2;
        if (pSidplay2->load(pTune) == -1)
        {
            //printf("There was a problem loading the sid tune.");
        }

        // configure chip output using the sid2_config_t structure
        sid2_config_t sid2config;
       
        ReSIDBuilder resid("name");
        resid.create(1);
       
        sid2config.frequency = pAudioConfig->frequency;
        sid2config.emulateStereo = true;
        sid2config.leftVolume = 255;
        sid2config.rightVolume = 255;
        sid2config.clockSpeed = SID2_CLOCK_PAL;
        sid2config.optimisation = 1;
        sid2config.sampleFormat = SID2_BIG_UNSIGNED;
        sid2config.sidModel = SID2_MOS6581;
        sid2config.forceDualSids = false;
        sid2config.sidSamples = true;
        sid2config.playback = sid2_stereo;
        sid2config.environment = sid2_envR;
        sid2config.precision = pAudioConfig->precision;
        sid2config.sidEmulation = &resid;

        // Apply the confiuguration settings
        if (pSidplay2->config(sid2config) == -1)
        {
            //pSidplay2->error();
            //printf(pSidplay2->error());
        }
        else
        {
            //printf("Configuration settings successfully applied");
        }

        // Play tune - needs something other than infinity i.e. check to see if song and loop until it finishes.....
        for(;;)
        {
            pSidplay2->play(pBuffer, pAudioConfig->bufSize);
            //pBuffer = pAudioDriver->write();
        }

        // Clean up - will need to implement this properly.....
        pAudioDriver->close();
    }

    At the moment I have a single function to play a tune. The project is set up as a dynamic dll, automatically created by VS2003 and customised by me. I don't understand why it worked as an .exe but will not work as a .dll. Are there fundamental differences?

    Many thanks,

    Damien.

     
    • Damien

      Damien - 2007-01-08

      Don't worry guys, fixed it, turned out to be a corrupot project file!?

      Anyway now have the library playing tunes through C# using DLLImport. I'm passing a handle from the current form into the exported function and running the playback on a backgroundworked thread. Works like a charm. Now i'm going to work on building a decent C# implemtation before looking at the possibility of constructing a COM wrapper and potentially a DirectShow filter.....

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks