static void instrument_type_cb (GtkComboBox *box) { gint item; item = gtk_combo_box_get_active(box); switch (item) { case SCPI_NONE: current_instrument = NULL; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(scpi_none_radio), TRUE); gtk_widget_hide(scpi_radio_conf); gtk_widget_hide(scpi_output); break; case SCPI_TX: load_instrument(&signal_generator); gtk_widget_show(scpi_radio_conf); if (current_instrument->control_socket) gtk_widget_show(scpi_output); else gtk_widget_hide(scpi_output); break; case SCPI_RX: load_instrument(&spectrum_analyzer); gtk_widget_show(scpi_radio_conf); if (current_instrument->ttyfd) gtk_widget_show(scpi_output); else gtk_widget_hide(scpi_output); break; default: printf("Unknown selection in %s:%s: %s\n", __FILE__, __func__, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(box))); break; } }
int set_default_instrument(char *name) { Instrument *ip; if (!(ip=load_instrument(name, 0, -1, -1, -1, 0, 0, 0))) return -1; if (default_instrument) free_instrument(default_instrument); default_instrument=ip; default_program=SPECIAL_PROGRAM; return 0; }
int set_default_instrument(char *name) { InstrumentLayer *lp; /* if (!(lp=load_instrument(name, 0, -1, -1, -1, 0, 0, 0))) */ if (!(lp=load_instrument(name, FONT_NORMAL, 0, -1, -1, 0, -1, -1, -1, -1, 0, -1, -1))) return -1; if (default_instrument) free_layer(default_instrument); default_instrument=lp; default_program=SPECIAL_PROGRAM; return 0; }
int Renderer::set_default_instrument(const char *name) { Instrument *ip; if ((ip = load_instrument(this, name, 0, -1, -1, 0, 0, 0)) == NULL) { return -1; } if (default_instrument != NULL) { delete default_instrument; } default_instrument = ip; default_program = SPECIAL_PROGRAM; return 0; }
CPLoader::Error CPLoader_IT::load_instruments() { for (int i=0;i<header.insnum;i++) { file->seek(0xC0+header.ordnum+i*4); uint32_t final_location=file->get_dword(); file->seek( final_location ); Error err=load_instrument( song->get_instrument( i ) ); if (err) return err; } return FILE_OK; if (file->eof_reached() || file->get_error()) return FILE_CORRUPTED; }
static int fill_bank(Renderer *song, int dr, int b) { int i, errors = 0; ToneBank *bank = ((dr) ? drumset[b] : tonebank[b]); if (bank == NULL) { cmsg(CMSG_ERROR, VERB_NORMAL, "Huh. Tried to load instruments in non-existent %s %d\n", (dr) ? "drumset" : "tone bank", b); return 0; } for (i = 0; i < MAXPROG; i++) { if (bank->instrument[i] == MAGIC_LOAD_INSTRUMENT) { bank->instrument[i] = NULL; bank->instrument[i] = load_instrument_dls(song, dr, b, i); if (bank->instrument[i] != NULL) { continue; } Instrument *ip; ip = load_instrument_font_order(song, 0, dr, b, i); if (ip == NULL) { if (bank->tone[i].fontbank >= 0) { ip = load_instrument_font(song, bank->tone[i].name, dr, b, i); } else { ip = load_instrument(song, bank->tone[i].name, (dr) ? 1 : 0, bank->tone[i].pan, (bank->tone[i].note != -1) ? bank->tone[i].note : ((dr) ? i : -1), (bank->tone[i].strip_loop != -1) ? bank->tone[i].strip_loop : ((dr) ? 1 : -1), (bank->tone[i].strip_envelope != -1) ? bank->tone[i].strip_envelope : ((dr) ? 1 : -1), bank->tone[i].strip_tail); } if (ip == NULL) { ip = load_instrument_font_order(song, 1, dr, b, i); } } bank->instrument[i] = ip; if (ip == NULL) { if (bank->tone[i].name.IsEmpty()) { cmsg(CMSG_WARNING, (b != 0) ? VERB_VERBOSE : VERB_NORMAL, "No instrument mapped to %s %d, program %d%s\n", (dr) ? "drum set" : "tone bank", b, i, (b != 0) ? "" : " - this instrument will not be heard"); } else { cmsg(CMSG_ERROR, VERB_NORMAL, "Couldn't load instrument %s (%s %d, program %d)\n", bank->tone[i].name.GetChars(), (dr) ? "drum set" : "tone bank", b, i); } if (b != 0) { /* Mark the corresponding instrument in the default bank / drumset for loading (if it isn't already) */ if (((dr) ? drumset[0] : tonebank[0])->instrument[i] != NULL) { ((dr) ? drumset[0] : tonebank[0])->instrument[i] = MAGIC_LOAD_INSTRUMENT; } } errors++; } } } return errors; }
bool pmd_load(const char *fname) { FILE *fp; int i, t; stat("----------------------"); stat("pmd_load: opening '%s'", fname); fp = fopen(fname, "rb"); if (!fp) { staterr("pmd_load: failed to open '%s'", fname); return 1; } if (!fverifystring(fp, "PMD")) { staterr("pmd_load: not a PMD file: '%s'", fname); fclose(fp); return 1; } fgetc(fp); // I dunno fgetl(fp); // I dunno song.ms_per_beat = fgetl(fp); // music wait song.loop_start = fgetl(fp); song.loop_end = fgetl(fp); song.nnotes = fgetl(fp); stat("song wait: %d (0x%04x)", song.ms_per_beat, song.ms_per_beat); stat("nnotes: %d (0x%04x)", song.nnotes, song.nnotes); stat("loop: %d-%d", song.loop_start, song.loop_end); // original PiyoPiyo and Ikachan seem to play things slightly slower than specified, // although PiyoPiyoPlayer plays it as spec'd in the file. if (strstr(fname, "Buriki")) song.ms_per_beat += 10; else song.ms_per_beat += 5; // load instrument samples for(i=0;i<NUM_TRACKS;i++) load_instrument(fp, &song.track[i].instrument); for(i=0;i<TOTAL_TRACKS;i++) song.track[i].no = i; // drum volume song.drum_volume = fgetl(fp); // load music notes for(t=0;t<TOTAL_TRACKS;t++) { stTrack *track = &song.track[t]; for(i=0;i<song.nnotes;i++) { uint32_t mask = fgetl(fp); track->note[i].notemask = (mask & 0xffffff); track->note[i].panning = (mask >> 24); if (!track->note[i].panning) track->note[i].panning = PAN_CENTER; else track->note[i].panning--; } } return 0; }
static int fill_bank(int dr, int b) { int i, errors=0; ToneBank *bank=((dr) ? drumset[b] : tonebank[b]); if (!bank) { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Huh. Tried to load instruments in non-existent %s %d", (dr) ? "drumset" : "tone bank", b); return 0; } for (i=0; i<MAXPROG; i++) { if (bank->tone[i].layer==MAGIC_LOAD_INSTRUMENT) { if (!(bank->tone[i].name)) { ctl->cmsg(CMSG_WARNING, (b!=0) ? VERB_VERBOSE : VERB_NORMAL, "No instrument mapped to %s %d, program %d%s", (dr)? "drum set" : "tone bank", b, i, (b!=0) ? "" : " - this instrument will not be heard"); if (b!=0) { /* Mark the corresponding instrument in the default bank / drumset for loading (if it isn't already) */ if (!dr) { if (!(standard_tonebank.tone[i].layer)) standard_tonebank.tone[i].layer= MAGIC_LOAD_INSTRUMENT; } else { if (!(standard_drumset.tone[i].layer)) standard_drumset.tone[i].layer= MAGIC_LOAD_INSTRUMENT; } } bank->tone[i].layer=0; errors++; } else if (!(bank->tone[i].layer= load_instrument(bank->tone[i].name, bank->tone[i].font_type, (dr) ? 1 : 0, bank->tone[i].pan, bank->tone[i].amp, bank->tone[i].tuning, (bank->tone[i].note!=-1) ? bank->tone[i].note : ((dr) ? i : -1), (bank->tone[i].strip_loop!=-1) ? bank->tone[i].strip_loop : ((dr) ? 1 : -1), (bank->tone[i].strip_envelope != -1) ? bank->tone[i].strip_envelope : ((dr) ? 1 : -1), bank->tone[i].strip_tail, b, ((dr) ? i + 128 : i), bank->tone[i].sf_ix ))) { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Couldn't load instrument %s (%s %d, program %d)", bank->tone[i].name, (dr)? "drum set" : "tone bank", b, i); errors++; } else { /* it's loaded now */ bank->tone[i].last_used = current_tune_number; current_patch_memory += bank->tone[i].layer->size; purge_as_required(); if (current_patch_memory > max_patch_memory) { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Not enough memory to load instrument %s (%s %d, program %d)", bank->tone[i].name, (dr)? "drum set" : "tone bank", b, i); errors++; free_layer(bank->tone[i].layer); bank->tone[i].layer=0; bank->tone[i].last_used=-1; } #if 0 if (check_for_rc()) { free_layer(bank->tone[i].layer); bank->tone[i].layer=0; bank->tone[i].last_used=-1; return 0; } #endif } } } return errors; }
static int fill_bank(int dr, int b) { int i, errors=0; ToneBank *bank=((dr) ? drumset[b] : tonebank[b]); if (!bank) { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Huh. Tried to load instruments in non-existent %s %d", (dr) ? "drumset" : "tone bank", b); return 0; } for (i=0; i<128; i++) { if (bank->tone[i].instrument==MAGIC_LOAD_INSTRUMENT) { if (!(bank->tone[i].name)) { ctl->cmsg(CMSG_WARNING, (b!=0) ? VERB_VERBOSE : VERB_NORMAL, "No instrument mapped to %s %d, program %d%s", (dr)? "drum set" : "tone bank", b, i, (b!=0) ? "" : " - this instrument will not be heard"); if (b!=0) { /* Mark the corresponding instrument in the default bank / drumset for loading (if it isn't already) */ if (!dr) { if (!(standard_tonebank.tone[i].instrument)) standard_tonebank.tone[i].instrument= MAGIC_LOAD_INSTRUMENT; } else { if (!(standard_drumset.tone[i].instrument)) standard_drumset.tone[i].instrument= MAGIC_LOAD_INSTRUMENT; } } bank->tone[i].instrument=0; errors++; } else if (!(bank->tone[i].instrument= load_instrument(bank->tone[i].name, (dr) ? 1 : 0, bank->tone[i].pan, bank->tone[i].amp, (bank->tone[i].note!=-1) ? bank->tone[i].note : ((dr) ? i : -1), (bank->tone[i].strip_loop!=-1) ? bank->tone[i].strip_loop : ((dr) ? 1 : -1), (bank->tone[i].strip_envelope != -1) ? bank->tone[i].strip_envelope : ((dr) ? 1 : -1), bank->tone[i].strip_tail ))) { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Couldn't load instrument %s (%s %d, program %d)", bank->tone[i].name, (dr)? "drum set" : "tone bank", b, i); errors++; } } } return errors; }
/* aux. function that completely loads instrument; my tests indicate that it's called somewhere around IDirectMusicCollection_GetInstrument */ HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM stream) { ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface); LARGE_INTEGER move; FOURCC fourcc; DWORD bytes; HRESULT hr; TRACE("(%p, %p, offset = %s)\n", This, stream, wine_dbgstr_longlong(This->liInstrumentPosition.QuadPart)); hr = IStream_Seek(stream, This->liInstrumentPosition, STREAM_SEEK_SET, NULL); if(FAILED(hr)){ WARN("IStream_Seek failed: %08x\n", hr); goto load_failure; } hr = read_from_stream(stream, &fourcc, sizeof(fourcc)); if(FAILED(hr)) goto load_failure; if(fourcc != FOURCC_LIST){ WARN("Loading failed: Expected LIST chunk, got: %s\n", debugstr_fourcc(fourcc)); goto load_failure; } hr = read_from_stream(stream, &bytes, sizeof(bytes)); if(FAILED(hr)) goto load_failure; TRACE("LIST chunk: %u bytes\n", bytes); while(1){ hr = read_from_stream(stream, &fourcc, sizeof(fourcc)); if(FAILED(hr)) goto load_failure; switch(fourcc){ case FOURCC_INS: TRACE("INS chunk: (no byte count)\n"); hr = load_instrument(This, stream, bytes - sizeof(FOURCC)); if(FAILED(hr)) goto load_failure; break; default: hr = read_from_stream(stream, &bytes, sizeof(bytes)); if(FAILED(hr)) goto load_failure; TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(fourcc), bytes); move.QuadPart = bytes; hr = IStream_Seek(stream, move, STREAM_SEEK_CUR, NULL); if(FAILED(hr)){ WARN("IStream_Seek failed: %08x\n", hr); return hr; } break; } } return S_OK; load_failure: return DMUS_E_UNSUPPORTED_STREAM; }