Esempio n. 1
0
bool YMPlugin::Load(char* filename)
{
    m_ymMusic = ymMusicCreate();
    if(!(m_valid = ymMusicLoad(m_ymMusic,filename)))
    {
        Unload();
        return m_valid;
    }

    ymMusicGetInfo(m_ymMusic,&m_ymInfo);
    m_Artist = m_ymInfo.pSongAuthor;
    m_Title = m_ymInfo.pSongName;
    m_Format = m_ymInfo.pSongType;
    m_Comments = m_ymInfo.pSongComment;
    m_FileName = filename;
    m_FileName.erase(0,m_FileName.rfind('\\') + 1);

    return m_valid;
}
Esempio n. 2
0
int main(int argc, char* argv[])
{

	//--------------------------------------------------------------------------
	// Checks args.
	//--------------------------------------------------------------------------
	printf(	"SmallYmPlayer.\n"
			"Using ST-Sound Library, under GPL license\n"
			"Copyright (C) 1995-1999 Arnaud Carre ( http://leonard.oxg.free.fr )\n");
	
	if (argc!=2)
	{
		printf("Usage: SmallYmPlayer <ym music file>\n\n");
		return -1;
	}


	//--------------------------------------------------------------------------
	// Load YM music and creates WAV file
	//--------------------------------------------------------------------------
	printf("Loading music \"%s\"...\n",argv[1]);
	YMMUSIC *pMusic = ymMusicCreate();

	if (ymMusicLoad(pMusic,argv[1]))
	{
		if (soundServer.open(soundServerCallback,500))
		{

			ymMusicInfo_t info;
			ymMusicGetInfo(pMusic,&info);
			printf("Name.....: %s\n",info.pSongName);
			printf("Author...: %s\n",info.pSongAuthor);
			printf("Comment..: %s\n",info.pSongComment);
			printf("Duration.: %d:%02d\n",info.musicTimeInSec/60,info.musicTimeInSec%60);

			printf("\nPlaying music...(press a key to abort)\n");

			ymMusicSetLoopMode(pMusic,YMTRUE);
			ymMusicPlay(pMusic);
			s_pMusic = pMusic;			// global instance for soundserver callback

			int oldSec = -1;
			for (;;)
			{
				if (_kbhit())
					break;

				int sec = ymMusicGetPos(pMusic) / 1000;
				if (sec != oldSec)
				{
					printf("Time: %d:%02d\r",sec/60,sec%60);
					oldSec = sec;
				}

				Sleep(20);
			}
			_getch();		// flush the key pressed
			printf("\n");

			// Switch off replayer
			s_pMusic = NULL;
			ymMusicStop(pMusic);
			soundServer.close();

		}
		else
		{
			printf("ERROR: Unable to initialize sound card hardware\n");
		}

	}
	else
	{
		printf("Error in loading file %s:\n%s\n",argv[1],ymMusicGetLastError(pMusic));
	}

	ymMusicDestroy(pMusic);

	return 0;
}