/* bass initialization */


void Error(char *text) 
{
    printf("Error(%d): %s\n",BASS_ErrorGetCode(),text);
    BASS_Free();
//    ExitProcess(0);
}

void CALLBACK LoopSync(HSYNC handle, DWORD channel, DWORD data, DWORD user) { }


HSTREAM str;

int za_malo_penazi_vela_muziky() 
{
    HMUSIC mod;

    if (BASS_GetVersion()!=MAKELONG(0,8)) {
            printf("BASS version 0.8 was not loaded\n");
            return 0;
    }

    if (!BASS_Init(-1,44100,0,hWnd)) 
       {
       Error("Can't initialize sound device");
       SendMessage(hWnd,WM_CLOSE,0,0);
       return 0;
       }

    switch (na_fest)
      {
      case 0:

       if (str=BASS_StreamCreateFile(FALSE,(void *)module_name,0,0,BASS_MP3_SETPOS))
          {
          BASS_ChannelSetSync(str,BASS_SYNC_END,0,&LoopSync,0);
          } 
          else {
                if (!(mod=BASS_MusicLoad(FALSE,(void *)module_name,0,0,BASS_MUSIC_RAMP)))
                   {
                   Error("Can't play the music file");      
                   SendMessage(hWnd,WM_CLOSE,0,0);
                   return 0;
                   }
                BASS_ChannelSetSync(mod,BASS_SYNC_END,0,&LoopSync,0);
               }
       break;
      case 1:

       if (str=BASS_StreamCreateFile(FALSE,(void *)module_name_na_fest,0,0,BASS_MP3_SETPOS))
          {
          BASS_ChannelSetSync(str,BASS_SYNC_END,0,&LoopSync,0);
          } 
          else {
                if (!(mod=BASS_MusicLoad(FALSE,(void *)module_name_na_fest,0,0,BASS_MUSIC_RAMP)))
                   {
                   Error("Can't play the music file");      
                   SendMessage(hWnd,WM_CLOSE,0,0);
                   return 0;
                   }
                BASS_ChannelSetSync(mod,BASS_SYNC_END,0,&LoopSync,0);
               }
       break;
      }

    BASS_Start();

    if (str) BASS_StreamPlay(str,FALSE,BASS_SAMPLE_LOOP);
        else BASS_MusicPlayEx(mod,0,-1,1);
    return 1;
}