void get_info( file_info & p_info, abort_callback & p_abort ) { YMMUSIC * m_info = ymMusicCreate(); ymMusicLoadMemory(m_info,file_buffer.get_ptr(), file_buffer.get_size()); ymMusicInfo_t info; ymMusicGetInfo(m_info,&info); p_info.info_set( "encoding", "synthesized" ); p_info.info_set( "codec", "YM" ); p_info.info_set_int( "channels", 1 ); p_info.meta_set( "title", pfc::stringcvt::string_utf8_from_ansi( info.pSongName) ); p_info.meta_set( "artist", pfc::stringcvt::string_utf8_from_ansi( info.pSongAuthor) ); p_info.meta_set( "comment", pfc::stringcvt::string_utf8_from_ansi( info.pSongComment) ); p_info.set_length( info.musicTimeInSec ); ymMusicDestroy(m_info); }
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; }
void open( service_ptr_t<file> m_file, const char * p_path, t_input_open_reason p_reason, abort_callback & p_abort ) { if ( p_reason == input_open_info_write ) throw exception_io_data(); input_open_file_helper( m_file, p_path, p_reason, p_abort ); m_stats = m_file->get_stats( p_abort ); t_uint8 * ptr; unsigned size; t_filesize size64 = m_file->get_size_ex( p_abort ); if ( size64 > ( 1 << 24 ) ) throw exception_io_data(); size = (unsigned) size64; file_buffer.set_size( size ); ptr = file_buffer.get_ptr(); m_file->read_object( ptr, size, p_abort ); bool yay = ymMusicLoadMemory(m_player,ptr,size); if ( !yay ) throw exception_io_data(); ymMusicGetInfo(m_player,&m_info); }
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; }