
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include "d:\dsik\dsik\include\audio.h"
#include "d:\dsik\dsik\include\import.h"
#include "d:\dsik\dsik\include\timer.h"


void main(void)
    {
        int t=0;
        DSM *M;
        SoundCard SC;

        dRegisterDrivers();
        if (dLoadSetup(&SC,"SETUP.CFG")) {
            printf("Please run SETUP.EXE to configure.\n");
            exit(EXIT_FAILURE);
        }
        if (dInit(&SC)) {
            printf("Error initializing the sound system.\n");
            exit(0);
        }
//       if (!(M = dLoadModule("SONG.DSM")))
          if (!(M = dImportModule("dark.s3m",FORM_S3M)))
            {printf("error de importacion");exit(0);}
        dSetupVoices(M->Header.NumTracks+3,M->Header.MasterVolume);
        dPlayMusic(M);

        dInitTimer();
        atexit(dDoneTimer);
        dStartTimer(dPoll,TICKS(70));



        while (t!='x')
                {
                     if (kbhit()) t=getch();
                     switch(t)
                        {
                        case '0':
                                   dPlayVoice(M->Header.NumTracks+1,M->Samples[0]);
                                   break;
                        case '1':
                                   dPlayVoice(M->Header.NumTracks+1,M->Samples[1]);
                                   break;
                        case '2':
                                   dPlayVoice(M->Header.NumTracks+1,M->Samples[2]);
                                   break;
                        case '3':
                                   dPlayVoice(M->Header.NumTracks+1,M->Samples[3]);
                                   break;
                        case '4':
                                   dPlayVoice(M->Header.NumTracks+1,M->Samples[4]);
                                   break;
                        default:break;
                        }
                }

        dStopMusic();
        dFreeModule(M);
    }
