int TrackCount(const char* strFile) { void* file = XBMC->OpenFile(strFile, 0); if (!file) return 1; int len = XBMC->GetFileLength(file); uint8_t* data = new uint8_t[len]; XBMC->ReadFile(file, data, len); XBMC->CloseFile(file); ASAP* asap = ASAP_New(); // Now load the module if (!ASAP_Load(asap, strFile, data, len)) { ASAP_Delete(asap); delete[] data; return 1; } delete[] data; const ASAPInfo* info = ASAP_GetInfo(asap); int result = ASAPInfo_GetSongs(info); ASAP_Delete(asap); return result; }
static void getTitle(char *title) { if (ASAPInfo_GetSongs(title_info) > 1) sprintf(title, "%s (song %d)", ASAPInfo_GetTitleOrFilename(title_info), title_song + 1); else strcpy(title, ASAPInfo_GetTitleOrFilename(title_info)); }
static Tuple *probe_for_tuple(const char *filename, VFSFile *file) { int song = -1; unsigned char module[ASAPInfo_MAX_MODULE_LENGTH]; int module_len; ASAPInfo *info = NULL; Tuple *tuple = NULL; int songs; int duration; int year; #if _AUD_PLUGIN_VERSION >= 10 char *real_filename = filename_split_subtune(filename, &song); if (real_filename != NULL) filename = real_filename; #endif module_len = load_module(filename, file, module); if (module_len > 0) { info = ASAPInfo_New(); if (info != NULL && ASAPInfo_Load(info, filename, module, module_len)) tuple = tuple_new_from_filename(filename); } #if _AUD_PLUGIN_VERSION >= 10 g_free(real_filename); #endif if (tuple == NULL) { ASAPInfo_Delete(info); return NULL; } tuple_set_nonblank(tuple, FIELD_ARTIST, ASAPInfo_GetAuthor(info)); tuple_set_nonblank(tuple, FIELD_TITLE, ASAPInfo_GetTitleOrFilename(info)); tuple_set_nonblank(tuple, FIELD_DATE, ASAPInfo_GetDate(info)); tuple_set_str(tuple, FIELD_CODEC, NULL, "ASAP"); songs = ASAPInfo_GetSongs(info); if (song > 0) { tuple_set_int(tuple, FIELD_SUBSONG_ID, NULL, song); tuple_set_int(tuple, FIELD_SUBSONG_NUM, NULL, songs); song--; } else { if (songs > 1) { #if _AUD_PLUGIN_VERSION >= 37 tuple_set_subtunes(tuple, songs, NULL); #else tuple->nsubtunes = songs; #endif } song = ASAPInfo_GetDefaultSong(info); } duration = ASAPInfo_GetDuration(info, song); if (duration > 0) tuple_set_int(tuple, FIELD_LENGTH, NULL, duration); year = ASAPInfo_GetYear(info); if (year > 0) tuple_set_int(tuple, FIELD_YEAR, NULL, year); ASAPInfo_Delete(info); return tuple; }
static void setSaved(void) { int i; _tcscpy(saved_author, ASAPInfo_GetAuthor(edited_info)); _tcscpy(saved_title, ASAPInfo_GetTitle(edited_info)); _tcscpy(saved_date, ASAPInfo_GetDate(edited_info)); for (i = 0; i < ASAPInfo_GetSongs(edited_info); i++) { saved_durations[i] = ASAPInfo_GetDuration(edited_info, i); saved_loops[i] = ASAPInfo_GetLoop(edited_info, i); } }
void get_info(t_uint32 p_subsong, file_info &p_info, abort_callback &p_abort) { int duration = get_song_duration(p_subsong, false); if (duration >= 0) p_info.set_length(duration / 1000.0); const ASAPInfo *info = ASAP_GetInfo(asap); p_info.info_set_int("channels", ASAPInfo_GetChannels(info)); p_info.info_set_int("subsongs", ASAPInfo_GetSongs(info)); meta_set(p_info, "composer", ASAPInfo_GetAuthor(info)); meta_set(p_info, "title", ASAPInfo_GetTitle(info)); meta_set(p_info, "date", ASAPInfo_GetDate(info)); }
static void addFileSongs(HWND playlistWnd, fileinfo *fi, const ASAPInfo *info, int *index) { char *p = fi->file + strlen(fi->file); int song; for (song = 0; song < ASAPInfo_GetSongs(info); song++) { COPYDATASTRUCT cds; sprintf(p, "#%d", song + 1); fi->index = (*index)++; cds.dwData = IPC_PE_INSERTFILENAME; cds.lpData = fi; cds.cbData = sizeof(fileinfo); SendMessage(playlistWnd, WM_COPYDATA, 0, (LPARAM) &cds); } }
static void updateTech(void) { char buf[16000]; char *p = buf; const char *ext; int type; int i; ext = ASAPInfo_GetOriginalModuleExt(edited_info, saved_module, saved_module_len); if (ext != NULL) p += sprintf(p, "Composed in %s\r\n", ASAPInfo_GetExtDescription(ext)); i = ASAPInfo_GetSongs(edited_info); if (i > 1) { p += sprintf(p, "SONGS %d\r\n", i); i = ASAPInfo_GetDefaultSong(edited_info); if (i > 0) p += sprintf(p, "DEFSONG %d (song %d)\r\n", i, i + 1); } p += sprintf(p, ASAPInfo_GetChannels(edited_info) > 1 ? "STEREO\r\n" : "MONO\r\n"); p += sprintf(p, ASAPInfo_IsNtsc(edited_info) ? "NTSC\r\n" : "PAL\r\n"); type = ASAPInfo_GetTypeLetter(edited_info); if (type != 0) p += sprintf(p, "TYPE %c\r\n", type); p += sprintf(p, "FASTPLAY %d (%d Hz)\r\n", ASAPInfo_GetPlayerRateScanlines(edited_info), ASAPInfo_GetPlayerRateHz(edited_info)); if (type == 'C') p += sprintf(p, "MUSIC %04X\r\n", ASAPInfo_GetMusicAddress(edited_info)); if (type != 0) { p = appendAddress(p, "INIT %04X\r\n", ASAPInfo_GetInitAddress(edited_info)); p = appendAddress(p, "PLAYER %04X\r\n", ASAPInfo_GetPlayerAddress(edited_info)); p = appendAddress(p, "COVOX %04X\r\n", ASAPInfo_GetCovoxAddress(edited_info)); } i = ASAPInfo_GetSapHeaderLength(edited_info); if (i >= 0) { while (p < buf + sizeof(buf) - 17 && i + 4 < saved_module_len) { int start = saved_module[i] + (saved_module[i + 1] << 8); int end; if (start == 0xffff) { i += 2; start = saved_module[i] + (saved_module[i + 1] << 8); } end = saved_module[i + 2] + (saved_module[i + 3] << 8); p += sprintf(p, "LOAD %04X-%04X\r\n", start, end); i += 5 + end - start; } } chomp(buf); SendDlgItemMessage(infoDialog, IDC_TECHINFO, WM_SETTEXT, 0, (LPARAM) buf); }
static BOOL infoChanged(void) { int i; if (_tcscmp(ASAPInfo_GetAuthor(edited_info), saved_author) != 0) return TRUE; if (_tcscmp(ASAPInfo_GetTitle(edited_info), saved_title) != 0) return TRUE; if (_tcscmp(ASAPInfo_GetDate(edited_info), saved_date) != 0) return TRUE; for (i = 0; i < ASAPInfo_GetSongs(edited_info); i++) { if (ASAPInfo_GetDuration(edited_info, i) != saved_durations[i]) return TRUE; if (saved_durations[i] >= 0 && ASAPInfo_GetLoop(edited_info, i) != saved_loops[i]) return TRUE; } return FALSE; }
void updateInfoDialog(LPCTSTR filename, int song) { int songs; int i; if (infoDialog == NULL) return; if (edited_info == NULL) { edited_info = ASAPInfo_New(); if (astil == NULL) astil = ASTIL_New(); if (edited_info == NULL || astil == NULL) { closeInfoDialog(); return; } } else if (infoChanged()) return; if (!loadModule(filename, saved_module, &saved_module_len) || !ASAPInfo_Load(edited_info, filename, saved_module, saved_module_len)) { closeInfoDialog(); return; } setSaved(); can_save = isExt(filename, _T(".sap")); invalid_fields = 0; SendDlgItemMessage(infoDialog, IDC_FILENAME, WM_SETTEXT, 0, (LPARAM) filename); SendDlgItemMessage(infoDialog, IDC_AUTHOR, WM_SETTEXT, 0, (LPARAM) saved_author); SendDlgItemMessage(infoDialog, IDC_NAME, WM_SETTEXT, 0, (LPARAM) saved_title); SendDlgItemMessage(infoDialog, IDC_DATE, WM_SETTEXT, 0, (LPARAM) saved_date); SendDlgItemMessage(infoDialog, IDC_SONGNO, CB_RESETCONTENT, 0, 0); songs = ASAPInfo_GetSongs(edited_info); EnableWindow(GetDlgItem(infoDialog, IDC_SONGNO), songs > 1); for (i = 1; i <= songs; i++) { _TCHAR str[16]; _stprintf(str, _T("%d"), i); SendDlgItemMessage(infoDialog, IDC_SONGNO, CB_ADDSTRING, 0, (LPARAM) str); } if (song < 0) song = ASAPInfo_GetDefaultSong(edited_info); SendDlgItemMessage(infoDialog, IDC_SONGNO, CB_SETCURSEL, song, 0); setEditedSong(song); EnableWindow(GetDlgItem(infoDialog, IDC_SAVE), FALSE); updateTech(); }
static BOOL saveFile(LPCTSTR filename, BOOL tag) { BOOL isSap = isExt(filename, _T(".sap")); if (isSap) { int song = ASAPInfo_GetSongs(edited_info); while (--song >= 0 && ASAPInfo_GetDuration(edited_info, song) < 0); while (--song >= 0) { if (ASAPInfo_GetDuration(edited_info, song) < 0) { MessageBox(infoDialog, _T("Cannot save file because time not set for all songs"), _T("Error"), MB_OK | MB_ICONERROR); return FALSE; } } } if (!doSaveFile(filename, tag)) { MessageBox(infoDialog, _T("Cannot save file"), _T("Error"), MB_OK | MB_ICONERROR); // FIXME: delete file return FALSE; } if (isSap) setSaved(); return TRUE; }
t_uint32 get_subsong_count() { return ASAPInfo_GetSongs(ASAP_GetInfo(asap)); }
int EMSCRIPTEN_KEEPALIVE asapinfo_GetSongs() { return ASAPInfo_GetSongs(info); }
HRESULT GetData(LPCSHCOLUMNID pscid, PROPVARIANT *pvarData, BOOL vista) { if (!m_hasInfo) return S_FALSE; if (pscid->fmtid == FMTID_SummaryInformation) { if (pscid->pid == PIDSI_TITLE) return GetString(pvarData, ASAPInfo_GetTitle(m_pinfo)); if (pscid->pid == PIDSI_AUTHOR) return GetAuthors(pvarData, vista); } else if (pscid->fmtid == FMTID_MUSIC) { if (pscid->pid == PIDSI_ARTIST) return GetAuthors(pvarData, vista); if (pscid->pid == PIDSI_YEAR) { int year = ASAPInfo_GetYear(m_pinfo); if (year < 0) { pvarData->vt = VT_EMPTY; return S_OK; } pvarData->vt = VT_UI8; pvarData->ulVal = (ULONG) year; return S_OK; } } else if (pscid->fmtid == FMTID_AudioSummaryInformation) { if (pscid->pid == PIDASI_TIMELENGTH) { int duration = ASAPInfo_GetDuration(m_pinfo, ASAPInfo_GetDefaultSong(m_pinfo)); if (duration < 0) { pvarData->vt = VT_EMPTY; return S_OK; } if (g_windowsVer == WINDOWS_OLD) { duration /= 1000; char timeStr[16]; sprintf(timeStr, "%02d:%02d:%02d", duration / 3600, duration / 60 % 60, duration % 60); return GetString(pvarData, timeStr); } else { pvarData->vt = VT_UI8; pvarData->uhVal.QuadPart = 10000ULL * duration; return S_OK; } } if (pscid->pid == PIDASI_CHANNEL_COUNT) { pvarData->vt = VT_UI4; pvarData->ulVal = (ULONG) ASAPInfo_GetChannels(m_pinfo); return S_OK; } } else if (pscid->fmtid == CLSID_ASAPMetadataHandler) { if (pscid->pid == 1) { pvarData->vt = VT_UI4; pvarData->ulVal = (ULONG) ASAPInfo_GetSongs(m_pinfo); return S_OK; } if (pscid->pid == 2) return GetString(pvarData, ASAPInfo_IsNtsc(m_pinfo) ? "NTSC" : "PAL"); } return S_FALSE; }