void GFX_PP_Update(struct Patch *patch, bool is_loading){ printf("GFX_PP_Update %s\n", patch==NULL?"(null)":patch->name); called_from_pp_update = true;{ //if(g_currpatch==patch) // goto exit; if(patch==NULL){ //g_instruments_widget->tabs->showPage(no_instrument_widget); }else if(patch->instrument==get_MIDI_instrument()){ printf("PP update. Instrument name: \"%s\". port name: \"%s\"\n",patch==NULL?"(null)":patch->name,patch==NULL?"(null)":((struct PatchData*)patch->patchdata)->midi_port->name); MIDI_instrument_widget *instrument = get_midi_instrument_widget(patch); if(instrument==NULL){ instrument = create_midi_instrument(patch); //instrument = get_midi_instrument_widget(patch); } update_midi_instrument_widget(instrument,patch); g_instruments_widget->tabs->setCurrentWidget(instrument); MW_update_all_chips(); MIDI_SetThroughPatch(patch); }else if(patch->instrument==get_audio_instrument()){ Audio_instrument_widget *instrument = get_audio_instrument_widget(patch); if(instrument==NULL){ fprintf(stderr," WARNING: patch %s didn't have an instrument widget. Creating one now. (Might happen when loading song or starting up. Nothing is wrong if that is the case)\n",patch->name); instrument = create_audio_instrument_widget(patch, true); //instrument = get_audio_instrument_widget(patch); } update_audio_instrument_widget(instrument,patch); g_instruments_widget->tabs->setCurrentWidget(instrument); //if (instrument->_sample_requester_widget != NULL && !is_loading) // instrument->_sample_requester_widget->update_file_list_if_needed(); MW_update_all_chips(); MIDI_SetThroughPatch(patch); }else if(patch->instrument!=NULL){ RError("PP_Update: Don't know how to handle instrument %p",patch->instrument); } // background color for editor tracks assigned to current instrument are slightly different than background color for non-current instruments. if(patch!=NULL && patch_used_in_current_editor_block(patch)) root->song->tracker_windows->must_redraw = true; else if (g_currpatch != NULL && patch_used_in_current_editor_block(g_currpatch)) root->song->tracker_windows->must_redraw = true; g_currpatch = patch; redrawMixerStrips(false); } //exit: called_from_pp_update = false; }
void GFX_update_instrument_widget(struct Patch *patch){ if (patch==NULL) return; if(patch->instrument==get_MIDI_instrument()){ printf("PP update. Instrument name: \"%s\". port name: \"%s\"\n",patch==NULL?"(null)":patch->name,patch==NULL?"(null)":((struct PatchData*)patch->patchdata)->midi_port->name); MIDI_instrument_widget *instrument = get_midi_instrument_widget(patch); if(instrument==NULL){ return; } if (instrument->isVisible()) update_midi_instrument_widget(instrument,patch); }else if(patch->instrument==get_audio_instrument()){ Audio_instrument_widget *instrument = get_audio_instrument_widget(patch); if(instrument==NULL){ printf("GFX_update_instrument_widget. instrument==NULL\n"); return; } if (instrument->isVisible()) update_audio_instrument_widget(instrument,patch); } }
static void make_patches_usable(struct Tracks *track){ struct Patch *old_patch = track->patch; if (old_patch != NULL) { struct Patch *new_patch = old_patch; if (!old_patch->is_usable) { R_ASSERT(old_patch->instrument == get_audio_instrument()); // Only audio instruments may not be usable. printf("PERMANENT_ID for %s: %d\n",old_patch->name,old_patch->permanent_id); if (old_patch->permanent_id != 0) new_patch = AUDIO_get_the_replacement_for_old_permanent_patch(old_patch); else { new_patch = PATCH_create_audio(NULL, NULL, old_patch->name, old_patch->state, 0, 0); connectAudioInstrumentToMainPipe(new_patch->id); } track->patch = new_patch; } R_ASSERT(track->patch->patchdata != NULL); VECTOR_FOR_EACH(struct FXs *fxs, &track->fxs){ struct FX *fx = fxs->fx; if (fx->patch == old_patch) fx->patch = new_patch; else if (!fx->patch->is_usable){ R_ASSERT(old_patch->instrument == get_audio_instrument()); // Only audio instruments may not be usable. if (fx->patch->permanent_id != 0) fx->patch = AUDIO_get_the_replacement_for_old_permanent_patch(fx->patch); else fx->patch = PATCH_create_audio(NULL, NULL, fx->patch->name, fx->patch->state, 0, 0); } }END_VECTOR_FOR_EACH; } }
bool TRACK_has_peaks(struct Tracks *track){ struct Patch *patch=track->patch; if(patch==NULL || patch->patchdata==NULL) return false; if(patch->instrument==get_audio_instrument() && ((SoundPlugin*)patch->patchdata)->type->get_peaks!=NULL){ return true; }else{ return false; } }
static void draw_slot(MyScene *myscene, float x, float y){ float x1,y1,x2,y2; int slot_x = get_slot_x(x); int slot_y = get_slot_y(y); get_slot_coordinates(slot_x, slot_y, x1,y1,x2,y2); #if 0 if(_current_slot==NULL){ QColor color(40,40,40); _current_slot = myscene->addRect(0,0,x2-x1,y2-y1, QPen(color), Qt::SolidPattern); //_current_slot->setZValue(-1); } #endif QGraphicsView *view = g_mixer_widget->view; const QRectF visibleRect = view->visibleRect(); //printf("slot x1: %d (visible x1: %d). slot y1: %d (visible y1: %d)\n",(int)x1,(int)visibleRect.left(),(int)y1,(int)visibleRect.top()); if(y2 >= visibleRect.bottom()) return; if(x2 >= visibleRect.right()){ //printf("x2: %d, visible x2: %d\n",(int)x2,(int)visibleRect.right()); return; } if(y1 <= visibleRect.top()) return; if(x1 < visibleRect.left()) return; //myscene->setSceneRect(myscene->itemsBoundingRect ()); // Dangerous. Crashes now and then. _slot_indicator->setPos(x1,y1); if (myscene->_moving_chips.size() > 0) return; #if 0 Chip *chip = MW_get_chip_at((x1+x2)/2, (y1+y2)/2, NULL); if (chip != NULL) { SoundPlugin *plugin = SP_get_plugin(chip->_sound_producer); volatile struct Patch *patch = plugin->patch; R_ASSERT_RETURN_IF_FALSE2(patch!=NULL,); struct Instruments *instrument = get_audio_instrument(); printf("Calling pp_update\n"); instrument->PP_Update(instrument,(struct Patch*)patch); MW_set_selected_chip(chip); }
// NOTE. This function can be called from a custom exec(). void AUDIOMETERPEAKS_call_very_often(int ms, int what_to_update){ static int counter = 0; counter+=ms; bool reset_falloff = false; if (counter>=1000*g_falloff_reset){ counter = 0; reset_falloff = true; } vector_t *audio_patches = &(get_audio_instrument()->patches); const int num_patches = audio_patches->num_elements; VECTOR_FOR_EACH(struct Patch *, patch, audio_patches){ SoundPlugin *plugin = (SoundPlugin*)patch->patchdata; if(plugin != NULL){ bool doit = true; int ms_to_use = what_to_update==-1 ? ms : ms*2; if (what_to_update==0 || what_to_update==1){ if (what_to_update==0 && iterator666 >= int(num_patches/2)) break; if (what_to_update==1 && !(iterator666 >= int(num_patches/2))) doit = false; } if (doit){ //printf("%d: Updating %d / %d\n", what_to_update, iterator666, num_patches); call_very_often(plugin, reset_falloff, ms_to_use); } } }END_VECTOR_FOR_EACH;