// Compile code in boot image so that we can execute the startup quotation // Allocates memory void factor_vm::prepare_boot_image() { std::cout << "*** Stage 2 early init... " << std::flush; // Compile all words. data_root<array> words(instances(WORD_TYPE), this); cell n_words = array_capacity(words.untagged()); for (cell i = 0; i < n_words; i++) { data_root<word> word(array_nth(words.untagged(), i), this); FACTOR_ASSERT(!word->entry_point); jit_compile_word(word.value(), word->def, false); } update_code_heap_words(true); // Initialize all quotations data_root<array> quotations(instances(QUOTATION_TYPE), this); cell n_quots = array_capacity(quotations.untagged()); for (cell i = 0; i < n_quots; i++) { data_root<quotation> quot(array_nth(quotations.untagged(), i), this); if (!quot->entry_point) quot->entry_point = lazy_jit_compile_entry_point(); } special_objects[OBJ_STAGE2] = special_objects[OBJ_CANONICAL_TRUE]; std::cout << "done" << std::endl; }
EnvelopeAndLfoParameters::~EnvelopeAndLfoParameters() { m_predelayModel.disconnect( this ); m_attackModel.disconnect( this ); m_holdModel.disconnect( this ); m_decayModel.disconnect( this ); m_sustainModel.disconnect( this ); m_releaseModel.disconnect( this ); m_amountModel.disconnect( this ); m_lfoPredelayModel.disconnect( this ); m_lfoAttackModel.disconnect( this ); m_lfoSpeedModel.disconnect( this ); m_lfoAmountModel.disconnect( this ); m_lfoWaveModel.disconnect( this ); m_x100Model.disconnect( this ); delete[] m_pahdEnv; delete[] m_rEnv; delete[] m_lfoShapeData; instances()->remove( this ); if( instances()->isEmpty() ) { delete instances(); s_lfoInstances = NULL; } }
std::vector<hpx::id_type> test_binpacking_multiple() { std::vector<hpx::id_type> keep_alive; // create an increasing number of instances on all available localities std::vector<std::vector<hpx::id_type> > targets; std::vector<hpx::id_type> localities = hpx::find_all_localities(); for (std::size_t i = 0; i != localities.size(); ++i) { hpx::id_type const& loc = localities[i]; targets.push_back(hpx::new_<test_server[]>(loc, i+1).get()); for (hpx::id_type const& id: targets.back()) { HPX_TEST(hpx::async<call_action>(id).get() == loc); keep_alive.push_back(id); } } std::string counter_name(hpx::components::default_binpacking_counter_name); counter_name += "test_server"; boost::uint64_t count = 0; for (std::size_t i = 0; i != localities.size(); ++i) { hpx::performance_counters::performance_counter instances( counter_name, localities[i]); count += instances.get_value<boost::uint64_t>(hpx::launch::sync); } // now use bin-packing policy to fill up the number of instances std::vector<hpx::id_type> filled_targets = hpx::new_<test_server[]>(hpx::binpacked(localities), count).get(); // now, all localities should have the same number of instances boost::uint64_t new_count = 0; for (std::size_t i = 0; i != localities.size(); ++i) { hpx::performance_counters::performance_counter instances( counter_name, localities[i]); boost::uint64_t c = instances.get_value<boost::uint64_t>(hpx::launch::sync); new_count += c; HPX_TEST_EQ(c, localities.size()+1); } HPX_TEST_EQ(2*count, new_count); for (hpx::id_type const& id: filled_targets) keep_alive.push_back(id); return keep_alive; }
Check::Check(const std::string &aname) : _tokenizer(0), _settings(0), _errorLogger(0), _name(aname) { for (std::list<Check*>::iterator i = instances().begin(); i != instances().end(); ++i) { if ((*i)->name() > aname) { instances().insert(i, this); return; } } instances().push_back(this); }
int main(int argc, char** argv) { InstanceManager instances(666, onMessageArrived); //Si este programa aun no esta corriendo if (instances.getInstancesCount() == 0) { instances.registerInstance(); controlador = new Controller(argc, argv); if (argc > 1 && String("--hidden") == argv[1]) { printf("Iniciando en modo oculto\n"); controlador->setVisible(false); } else { controlador->setVisible(true); } gtk_main(); delete controlador; } else{ int pid = instances.getPID(0); printf("%s\n", "Executado"); String command("add"); if (argc > 1 && command == argv[1]){ for (int i = 2; i < argc; i++){ command += String(":") + argv[i]; } printf("%s\n", command.c_str()); instances.send(pid, command, command.length()); } else{ printf("%s\n", "restore"); instances.send(pid, "restore", 7); } } return 0; }
// Configuration (CLOB) stuff. void qtractorDssiPlugin::configure ( const QString& sKey, const QString& sValue ) { if (m_phInstances == NULL) return; const DSSI_Descriptor *pDssiDescriptor = dssi_descriptor(); if (pDssiDescriptor == NULL) return; if (pDssiDescriptor->configure == NULL) return; #ifdef CONFIG_DEBUG qDebug("qtractorDssiPlugin[%p]::configure(\"%s\", \"%s\")", this, sKey.toUtf8().constData(), sValue.toUtf8().constData()); #endif // For each plugin instance... const unsigned short iInstances = instances(); for (unsigned short i = 0; i < iInstances; ++i) { (*pDssiDescriptor->configure)(m_phInstances[i], sKey.toUtf8().constData(), sValue.toUtf8().constData()); } #ifdef CONFIG_LIBLO if (m_pDssiEditor) { osc_send_configure(m_pDssiEditor, sKey.toUtf8().constData(), sValue.toUtf8().constData()); } #endif }
void test_binpacking_single() { // create an increasing number of instances on all available localities std::vector<std::vector<hpx::id_type> > targets; std::vector<hpx::id_type> localities = hpx::find_all_localities(); for (std::size_t i = 0; i != localities.size(); ++i) { hpx::id_type const& loc = localities[i]; targets.push_back(hpx::new_<test_server[]>(loc, i+1).get()); for (hpx::id_type const& id: targets.back()) { HPX_TEST(hpx::async<call_action>(id).get() == loc); } } std::string counter_name(hpx::components::default_binpacking_counter_name); counter_name += "test_server"; hpx::performance_counters::performance_counter instances( counter_name, localities[0]); boost::uint64_t before = instances.get_value_sync<boost::uint64_t>(); // now use bin-packing policy to create one more instance hpx::id_type filled_target = hpx::new_<test_server>( hpx::binpacked(localities)).get(); // now, the first locality should have one more instance boost::uint64_t after = instances.get_value_sync<boost::uint64_t>(); HPX_TEST_EQ(before+1, after); }
void Module::draw_box ( int tx, int ty, int tw, int th ) { fl_color( fl_contrast( FL_FOREGROUND_COLOR, color() ) ); fl_push_clip( tx, ty, tw, th ); Fl_Color c = color(); if ( ! active_r() ) c = fl_inactive( c ); int spacing = w() / instances(); for ( int i = instances(); i--; ) { fl_draw_box( box(), tx + (spacing * i), ty, tw / instances(), th, c ); } if ( audio_input.size() && audio_output.size() ) { /* maybe draw control indicators */ if ( control_input.size() ) { fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); /* fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + th - 8, 5, 5, is_being_controlled_osc() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); */ } if ( control_output.size() ) fl_draw_box( FL_ROUNDED_BOX, tx + tw - 8, ty + 4, 5, 5, is_controlling() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); } fl_push_clip( tx + Fl::box_dx(box()), ty + Fl::box_dy(box()), tw - Fl::box_dw(box()), th - Fl::box_dh(box()) ); Fl_Group::draw_children(); fl_pop_clip(); if ( focused_r( this ) ) draw_focus_frame( tx,ty,tw,th, selection_color() ); fl_pop_clip(); }
void Module::draw_box ( void ) { fl_color( fl_contrast( FL_FOREGROUND_COLOR, color() ) ); int tw, th, tx, ty; tw = w(); th = h(); ty = y(); tx = x(); fl_push_clip( tx, ty, tw, th ); Fl_Color c = is_default() ? FL_BLACK : color(); c = active() && ! bypass() ? c : fl_inactive( c ); int spacing = w() / instances(); for ( int i = instances(); i--; ) { fl_draw_box( box(), tx + (spacing * i), ty, tw / instances(), th, Fl::belowmouse() == this ? fl_lighter( c ) : c ); } if ( this == Fl::focus() ) { fl_draw_box( FL_UP_FRAME, x(), y(), w(), h(), selection_color() ); } if ( audio_input.size() && audio_output.size() ) { /* maybe draw control indicators */ if ( control_input.size() ) fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); if ( control_output.size() ) fl_draw_box( FL_ROUNDED_BOX, tx + tw - 8, ty + 4, 5, 5, is_controlling() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); } Fl_Group::draw_children(); fl_pop_clip(); }
// Do the actual deactivation. void qtractorLadspaPlugin::deactivate (void) { const LADSPA_Descriptor *pLadspaDescriptor = ladspa_descriptor(); if (pLadspaDescriptor == NULL) return; if (m_phInstances && pLadspaDescriptor->deactivate) { for (unsigned short i = 0; i < instances(); ++i) (*pLadspaDescriptor->deactivate)(m_phInstances[i]); } }
void ModelWriter::visitFaces(SUEntitiesRef ents, VisitorFunc func, bool recursive, Transform transform) { size_t count =0; SUEntitiesGetNumFaces(ents,&count); vector<SUFaceRef> faces(count); SUEntitiesGetFaces(ents,count,faces.data(),&count); for(int i=0; i < count; i++){ (*this.*func)(faces[i], transform); } SUEntitiesGetNumGroups(ents,&count); vector<SUGroupRef> groups(count); SUEntitiesGetGroups(ents,count,groups.data(),&count); for(int i=0; i < count; i++){ SUEntitiesRef ents2 = SU_INVALID; SUGroupGetEntities(groups[i],&ents2); Transform t; SUGroupGetTransform(groups[i], (SUTransformation*)&t); visitFaces(ents2,func,true, transform * t); } if(recursive) { SUEntitiesGetNumInstances(ents,&count); vector<SUComponentInstanceRef> instances(count); SUEntitiesGetInstances(ents,count,instances.data(),&count); for(int i=0; i < count; i++){ Transform t; SUComponentDefinitionRef def = SU_INVALID; SUEntitiesRef ents2 = SU_INVALID; SUComponentInstanceGetTransform(instances[i],(SUTransformation*)&t); SUComponentInstanceGetDefinition(instances[i],&def); SUComponentDefinitionGetEntities(def,&ents2); visitFaces(ents2,func,true, transform * t); } } }
// The main plugin processing procedure. void qtractorLadspaPlugin::process ( float **ppIBuffer, float **ppOBuffer, unsigned int nframes ) { if (m_phInstances == NULL) return; const LADSPA_Descriptor *pLadspaDescriptor = ladspa_descriptor(); if (pLadspaDescriptor == NULL) return; // We'll cross channels over instances... const unsigned short iInstances = instances(); const unsigned short iChannels = channels(); const unsigned short iAudioIns = audioIns(); const unsigned short iAudioOuts = audioOuts(); unsigned short iIChannel = 0; unsigned short iOChannel = 0; unsigned short i, j; // For each plugin instance... for (i = 0; i < iInstances; ++i) { LADSPA_Handle handle = m_phInstances[i]; // For each instance audio input port... for (j = 0; j < iAudioIns; ++j) { (*pLadspaDescriptor->connect_port)(handle, m_piAudioIns[j], ppIBuffer[iIChannel]); if (++iIChannel >= iChannels) iIChannel = 0; } // For each instance audio output port... for (j = 0; j < iAudioOuts; ++j) { (*pLadspaDescriptor->connect_port)(handle, m_piAudioOuts[j], ppOBuffer[iOChannel]); if (++iOChannel >= iChannels) iOChannel = 0; } // Make it run... (*pLadspaDescriptor->run)(handle, nframes); // Wrap channels?... if (iIChannel < iChannels - 1) ++iIChannel; if (iOChannel < iChannels - 1) ++iOChannel; } }
// Bank/program selector. void qtractorDssiPlugin::selectProgram ( int iBank, int iProg ) { if (iBank < 0 || iProg < 0) return; // HACK: We don't change program-preset when // we're supposed to be multi-timbral... if (list()->isMidiBus()) return; if (m_phInstances == NULL) return; const DSSI_Descriptor *pDssiDescriptor = dssi_descriptor(); if (pDssiDescriptor == NULL) return; if (pDssiDescriptor->select_program == NULL) return; #ifdef CONFIG_DEBUG qDebug("qtractorDssiPlugin[%p]::selectProgram(%d, %d)", this, iBank, iProg); #endif // For each plugin instance... const unsigned short iInstances = instances(); for (unsigned short i = 0; i < iInstances; ++i) (*pDssiDescriptor->select_program)(m_phInstances[i], iBank, iProg); #ifdef CONFIG_LIBLO // And update the editor too... if (m_pDssiEditor) osc_send_program(m_pDssiEditor, iBank, iProg); #endif // Reset parameters default value... const qtractorPlugin::Params& params = qtractorPlugin::params(); qtractorPlugin::Params::ConstIterator param = params.constBegin(); const qtractorPlugin::Params::ConstIterator& param_end = params.constEnd(); for ( ; param != param_end; ++param) { qtractorPluginParam *pParam = param.value(); pParam->setDefaultValue(pParam->value()); } }
int SkpModel::LoadEntitiesRecursive(SUEntitiesRef entities){ int out = 0; //Get Entities from Instances size_t instanceCount; SUResult res = SUEntitiesGetNumInstances(entities, &instanceCount); if (res != SU_ERROR_NONE) return 1; if (instanceCount > 0) { std::vector<SUComponentInstanceRef> instances(instanceCount); std::vector<SUEntitiesRef> entities2(instanceCount); SUEntitiesGetInstances(entities, instanceCount, &instances[0], &instanceCount); out += Instances2Entities(&instances, &entities2); for (size_t i = 0; i < instanceCount; i++) { entities_.push_back(entities2[i]); LoadEntitiesRecursive(entities2[i]); } } //Get Entities from groups size_t groupCount = 0; res = SUEntitiesGetNumGroups(entities, &groupCount); if (res != SU_ERROR_NONE) return 1; if (groupCount > 0){ std::vector<SUGroupRef> groups(groupCount); std::vector<SUEntitiesRef> entities2(groupCount); SUEntitiesGetGroups(entities, groupCount, &groups[0], &groupCount); out += Groups2Entities(&groups, &entities2); for (size_t i=0; i < groupCount; i++){ entities_.push_back(entities2[i]); LoadEntitiesRecursive(entities2[i]); } } return out; }
// Post-(re)initializer. void qtractorDssiPlugin::resetChannels (void) { // (Re)initialize controller port map, anyway. ::memset(m_apControllerMap, 0, 128 * sizeof(qtractorPluginParam *)); // Check how many instances are about there... const unsigned short iInstances = instances(); if (iInstances < 1) return; #ifdef CONFIG_DEBUG qDebug("qtractorDssiPlugin[%p]::resetChannels() instances=%u", this, iInstances); #endif // (Re)set according to existing instances... if (m_pDssiMulti) m_pDssiMulti->addPlugin(this); // Map all existing input control ports... const DSSI_Descriptor *pDssiDescriptor = dssi_descriptor(); if (pDssiDescriptor && pDssiDescriptor->get_midi_controller_for_port) { // Only the first one instance should matter... LADSPA_Handle handle = m_phInstances[0]; const qtractorPlugin::Params& params = qtractorPlugin::params(); qtractorPlugin::Params::ConstIterator param = params.constBegin(); const qtractorPlugin::Params::ConstIterator& param_end = params.constEnd(); for ( ; param != param_end; ++param) { qtractorPluginParam *pParam = param.value(); const int iController = (*pDssiDescriptor->get_midi_controller_for_port)( handle, pParam->index()); if (iController > 0 && DSSI_IS_CC(iController)) m_apControllerMap[DSSI_CC_NUMBER(iController)] = pParam; } } }
// The main plugin processing procedure. void qtractorDssiPlugin::process ( float **ppIBuffer, float **ppOBuffer, unsigned int nframes ) { // Get MIDI manager access... qtractorMidiManager *pMidiManager = list()->midiManager(); if (pMidiManager == NULL) { qtractorLadspaPlugin::process(ppIBuffer, ppOBuffer, nframes); return; } if (m_phInstances == NULL) return; const LADSPA_Descriptor *pLadspaDescriptor = ladspa_descriptor(); if (pLadspaDescriptor == NULL) return; const DSSI_Descriptor *pDssiDescriptor = dssi_descriptor(); if (pDssiDescriptor == NULL) return; // We'll cross channels over instances... const unsigned short iInstances = instances(); const unsigned short iChannels = channels(); const unsigned short iAudioIns = audioIns(); const unsigned short iAudioOuts = audioOuts(); unsigned short iIChannel = 0; unsigned short iOChannel = 0; unsigned short i, j; // For each plugin instance... for (i = 0; i < iInstances; ++i) { LADSPA_Handle handle = m_phInstances[i]; // For each instance audio input port... for (j = 0; j < iAudioIns; ++j) { (*pLadspaDescriptor->connect_port)(handle, m_piAudioIns[j], ppIBuffer[iIChannel]); if (++iIChannel >= iChannels) iIChannel = 0; } // For each instance audio output port... for (j = 0; j < iAudioOuts; ++j) { if (iOChannel < iChannels) { (*pLadspaDescriptor->connect_port)(handle, m_piAudioOuts[j], ppOBuffer[iOChannel++]); } else { (*pLadspaDescriptor->connect_port)(handle, m_piAudioOuts[j], m_pfXBuffer); // dummy output! } } // Care of multiple instances here... if (m_pDssiMulti) m_pDssiMulti->process(pDssiDescriptor, nframes); // Make it run... else if (pDssiDescriptor->run_synth) { (*pDssiDescriptor->run_synth)(handle, nframes, pMidiManager->events(), pMidiManager->count()); } else (*pLadspaDescriptor->run)(handle, nframes); #if 0 // Wrap channels?... if (iIChannel < iChannels - 1) ++iIChannel; if (iOChannel < iChannels - 1) ++iOChannel; #endif } }
void windy::app::on_assets_delete_pressed(nana::menu::item_proxy& ip) { if (this->_instance_creator->items().size() > 0) { switch (this->_instance_creator->category()) { case layer::kind::graphicable: { // references from graphicables and nuke { for (auto item : this->_instance_creator->items()) { for (auto instance : item->instances()) { this->_environment->project()->remove(instance); } auto sprite = std::dynamic_pointer_cast<content::sprite>(item); this->_environment->project()->remove_sprite(sprite); } } } break; case layer::kind::groupable: { for (auto item : this->_instance_creator->items()) { // references from compositions and nuke if single-animation remains { auto compositions = this->_environment->project()->assets()->collection()-> get(layer::kind::compositable); std::vector <std::shared_ptr<content::composition> > compositions_nuked; for (auto composition_item : compositions) { auto composition = std::dynamic_pointer_cast<content::composition> (composition_item); auto& instances = composition->instances(); for (auto instance : instances) { auto compositable = std::dynamic_pointer_cast <content::compositable>(instance); std::vector<std::shared_ptr<content::groupable> > groupables_nuked; for (auto child : compositable->children()) { auto groupable = std::dynamic_pointer_cast <content::groupable>(child); if (groupable->asset_uuid() == item->uuid()) { groupables_nuked.push_back(groupable); this->_environment->project()->assets()-> collection()->remove(groupable); } } for (auto nuked : groupables_nuked) { auto& children = compositable->children(); auto it = std::find(children.begin(), children.end(), nuked); children.erase(it); } } composition->unmap(item); if (composition->maps().empty()) { compositions_nuked.push_back(composition); } } for (auto composition : compositions_nuked) { for (auto instance : composition->instances()) { this->_environment->project()->remove(instance); } this->_environment->project()->remove_composition(composition); } } // nuke timeline triggers { for (auto instance : item->instances()) { auto groupable = std::dynamic_pointer_cast<content::groupable> (instance); for (auto trigger : groupable->triggers()) { this->_environment->timeline()->remove_trigger(trigger); } } } // references from groupables and nuke { auto instances = item->instances(); // copy by reference to store the instances for (auto instance : instances) { this->_environment->project()->remove(instance); } auto group = std::dynamic_pointer_cast<content::group>(item); this->_environment->project()->remove_group(group); } } } break; case layer::kind::compositable: { // references from compositables and nuke { for (auto item : this->_instance_creator->items()) { for (auto instance : item->instances()) { this->_environment->project()->remove(instance); } auto composition = std::dynamic_pointer_cast<content::composition>(item); this->_environment->project()->remove_composition(composition); } } } break; } // refresh { this->_environment->project()->assets()->refresh(); // this->_selection_targets.clear(); this->_environment->edition()->refresh(this->_environment->project()->game()->container()); this->_environment->properties()->clear(); this->_environment->trigger_recalculation(); } } else { nana::msgbox error(this->handle(), L"Error"); error << L"Please select one or more assets first."; error.show(); } }
~instance_counted_t() { instances()--; }
EnvelopeAndLfoParameters::EnvelopeAndLfoParameters( float _value_for_zero_amount, Model * _parent ) : Model( _parent ), m_used( false ), m_predelayModel( 0.0, 0.0, 2.0, 0.001, this, tr( "Predelay" ) ), m_attackModel( 0.0, 0.0, 2.0, 0.001, this, tr( "Attack" ) ), m_holdModel( 0.5, 0.0, 2.0, 0.001, this, tr( "Hold" ) ), m_decayModel( 0.5, 0.0, 2.0, 0.001, this, tr( "Decay" ) ), m_sustainModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Sustain" ) ), m_releaseModel( 0.1, 0.0, 2.0, 0.001, this, tr( "Release" ) ), m_amountModel( 0.0, -1.0, 1.0, 0.005, this, tr( "Modulation" ) ), m_valueForZeroAmount( _value_for_zero_amount ), m_pahdFrames( 0 ), m_rFrames( 0 ), m_pahdEnv( NULL ), m_rEnv( NULL ), m_pahdBufSize( 0 ), m_rBufSize( 0 ), m_lfoPredelayModel( 0.0, 0.0, 1.0, 0.001, this, tr( "LFO Predelay" ) ), m_lfoAttackModel( 0.0, 0.0, 1.0, 0.001, this, tr( "LFO Attack" ) ), m_lfoSpeedModel( 0.1, 0.001, 1.0, 0.0001, SECS_PER_LFO_OSCILLATION * 1000.0, this, tr( "LFO speed" ) ), m_lfoAmountModel( 0.0, -1.0, 1.0, 0.005, this, tr( "LFO Modulation" ) ), m_lfoWaveModel( SineWave, 0, NumLfoShapes, this, tr( "LFO Wave Shape" ) ), m_x100Model( false, this, tr( "Freq x 100" ) ), m_controlEnvAmountModel( false, this, tr( "Modulate Env-Amount" ) ), m_lfoFrame( 0 ), m_lfoAmountIsZero( false ), m_lfoShapeData( NULL ) { m_amountModel.setCenterValue( 0 ); m_lfoAmountModel.setCenterValue( 0 ); if( s_lfoInstances == NULL ) { s_lfoInstances = new LfoInstances(); } instances()->add( this ); connect( &m_predelayModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_attackModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_holdModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_decayModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_sustainModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_releaseModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_amountModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_lfoPredelayModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_lfoAttackModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_lfoSpeedModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_lfoAmountModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_lfoWaveModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( &m_x100Model, SIGNAL( dataChanged() ), this, SLOT( updateSampleVars() ) ); connect( engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleVars() ) ); m_lfoShapeData = new sample_t[engine::mixer()->framesPerPeriod()]; updateSampleVars(); }
void factor_vm::primitive_all_instances() { primitive_full_gc(); ctx->push(instances(TYPE_COUNT)); }
instance_counted_t(int i=0) : m_id(i) { instances()++; } // intentionally implicit
instance_counted_t(const instance_counted_t& other) : m_id(other.m_id) { instances()++; }
cell factor_vm::find_all_words() { return instances(WORD_TYPE); }
// Channel/instance number accessors. void qtractorLadspaPlugin::setChannels ( unsigned short iChannels ) { // Check our type... qtractorPluginType *pType = type(); if (pType == NULL) return; // Estimate the (new) number of instances... unsigned short iOldInstances = instances(); unsigned short iInstances = pType->instances(iChannels, list()->isMidi()); // Now see if instance count changed anyhow... if (iInstances == iOldInstances) return; const LADSPA_Descriptor *pLadspaDescriptor = ladspa_descriptor(); if (pLadspaDescriptor == NULL) return; // Gotta go for a while... bool bActivated = isActivated(); setActivated(false); // Set new instance number... setInstances(iInstances); if (m_phInstances) { if (pLadspaDescriptor->cleanup) { for (unsigned short i = 0; i < iOldInstances; ++i) (*pLadspaDescriptor->cleanup)(m_phInstances[i]); } delete [] m_phInstances; m_phInstances = NULL; } // Bail out, if none are about to be created... if (iInstances < 1) { setActivated(bActivated); return; } #ifdef CONFIG_DEBUG qDebug("qtractorLadspaPlugin[%p]::setChannels(%u) instances=%u", this, iChannels, iInstances); #endif // We'll need output control (not dummy anymore) port indexes... unsigned short iControlOuts = pType->controlOuts(); // Allocate new instances... m_phInstances = new LADSPA_Handle [iInstances]; for (unsigned short i = 0; i < iInstances; ++i) { // Instantiate them properly first... LADSPA_Handle handle = (*pLadspaDescriptor->instantiate)(pLadspaDescriptor, sampleRate()); // Connect all existing input control ports... const qtractorPlugin::Params& params = qtractorPlugin::params(); qtractorPlugin::Params::ConstIterator param = params.constBegin(); const qtractorPlugin::Params::ConstIterator& param_end = params.constEnd(); for ( ; param != param_end; ++param) { qtractorPluginParam *pParam = param.value(); // Just in case the plugin decides // to set the port value at this time... float *pfValue = pParam->subject()->data(); float fValue = *pfValue; (*pLadspaDescriptor->connect_port)(handle, pParam->index(), pfValue); // Make new one the default and restore port value... pParam->setDefaultValue(*pfValue); *pfValue = fValue; } // Connect all existing output control ports... for (unsigned short j = 0; j < iControlOuts; ++j) { (*pLadspaDescriptor->connect_port)(handle, m_piControlOuts[j], &m_pfControlOuts[j]); } // This is it... m_phInstances[i] = handle; } // (Re)issue all configuration as needed... realizeConfigs(); realizeValues(); // But won't need it anymore. releaseConfigs(); releaseValues(); // (Re)activate instance if necessary... setActivated(bActivated); }