Beispiel #1
0
GeneratorPtr Session::create_generator_from_node(TiXmlElement* element, Region* region){
    fsom::DebugStream << "Attempting to create generator"<<std::endl;
    GeneratorPtr gen = GeneratorPtr(new Generator(Generator::GEN_Sine,dspCreationStruct(region)));
    
    TiXmlElement* basicInfoElement = element->FirstChildElement("BasicInfo");
    if(basicInfoElement){
	fsom::DebugStream << "Generator basic info found"<<std::endl;
	int genType,noiseState;
	std::string path = basicInfoElement->Attribute("Path"); 
	basicInfoElement->QueryIntAttribute("GenType",&genType);
	basicInfoElement->QueryIntAttribute("NoiseState",&noiseState);
	Generator::GeneratorType type = Generator::GeneratorType(genType);
	gen->set_generator_voice(type);
	gen->set_noise_state(noiseState);
	gen->set_file_path(path);
	fsom::DebugStream << "noise state for gen set to "<<noiseState<<std::endl;
	fsom::DebugStream << "gen type = "<<genType<<std::endl;
	
	
	
    }
    
    TiXmlElement * child = element->FirstChildElement("Parameter");
    while(child){
      fsom::DebugStream << "Parameter in generator found"<<std::endl;
      ParameterPtr p = create_parameter_from_node(child, region);
      gen->get_parameter(p->get_name())->set_value(p->get_value());
      child = child->NextSiblingElement("Parameter");
    }
    
    return gen;
}
Beispiel #2
0
void LibraryModel::SaveGenerator(QSettings* s, int i,
                                 GeneratorPtr generator) const {
  s->setArrayIndex(i);
  s->setValue("name", generator->name());
  s->setValue("type", generator->type());
  s->setValue("data", generator->Save());
}
Beispiel #3
0
GeneratorPtr Wizard::CreateGenerator() const {
  GeneratorPtr ret;
  if (type_index_ == -1)
    return ret;

  ret = plugins_[type_index_]->CreateGenerator();
  if (!ret)
    return ret;

  ret->set_name(finish_page_->ui_->name->text());
  ret->set_dynamic(finish_page_->ui_->dynamic->isChecked());
  return ret;
}
Beispiel #4
0
GeneratorPtr LibraryModel::CreateGenerator(const QModelIndex& index) const {
  GeneratorPtr ret;

  const LibraryItem* item = IndexToItem(index);
  if (!item || item->type != LibraryItem::Type_SmartPlaylist) return ret;

  ret = Generator::Create(item->key);
  if (!ret) return ret;

  ret->set_name(item->display_text);
  ret->set_library(backend());
  ret->Load(item->smart_playlist_data);
  return ret;
}
Beispiel #5
0
      //-----------------------------------------------------------------------
      void Attribute::writeBufferXML(const GeneratorPtr &inGenerator, char * &ioPos) const
      {
        bool hasQuotes = mHasQuotes;

        ZS_THROW_INVALID_USAGE_IF(mName.isEmpty())
        Generator::writeBuffer(ioPos, mName);
        if (!mValuelessAttribute)
        {
          Generator::writeBuffer(ioPos, "=");
          char quote[2];
          quote[0] = (String::npos == mValue.find('\"') ? '\"' : '\'');
          quote[1] = 0;
          String value = mValue;
          if (0 != (XML::Generator::XMLWriteFlag_NormalizeCDATA & inGenerator->getXMLWriteFlags())) {
            quote[0] = '\"';
            value = normalizeAttributeValue(mValue);
            hasQuotes = true;
          }
          if (hasQuotes) {
            Generator::writeBuffer(ioPos, &(quote[0]));
          }
          Generator::writeBuffer(ioPos, value);
          if (hasQuotes) {
            Generator::writeBuffer(ioPos, &(quote[0]));
          }
        }
      }
Beispiel #6
0
void Wizard::SetGenerator(GeneratorPtr gen) {
  // Find the right type and jump to the start page
  for (int i=0 ; i<plugins_.count() ; ++i) {
    if (plugins_[i]->type() == gen->type()) {
      TypeChanged(i);
      // TODO: Put this back in when the setStartId is removed from the ctor
      // next();
      break;
    }
  }

  // Set the name
  finish_page_->ui_->name->setText(gen->name());
  finish_page_->ui_->dynamic->setChecked(gen->is_dynamic());

  // Tell the plugin to load
  plugins_[type_index_]->SetGenerator(gen);
}
Beispiel #7
0
void PlaylistManager::PlaySmartPlaylist(GeneratorPtr generator, bool as_new,
                                        bool clear) {
  if (as_new) {
    New(generator->name());
  }

  if (clear) {
    current()->Clear();
  }

  current()->InsertSmartPlaylist(generator);
}
Beispiel #8
0
void LibraryModel::UpdateGenerator(const QModelIndex& index, GeneratorPtr gen) {
  if (index.parent() != ItemToIndex(smart_playlist_node_)) return;
  LibraryItem* item = IndexToItem(index);
  if (!item) return;

  // Update the config
  QSettings s;
  s.beginGroup(kSmartPlaylistsSettingsGroup);

  // Count the existing items
  const int count = s.beginReadArray(backend_->songs_table());
  s.endArray();

  s.beginWriteArray(backend_->songs_table(), count);
  SaveGenerator(&s, index.row(), gen);

  // Update the text of the item
  item->display_text = gen->name();
  item->sort_text = item->display_text;
  item->key = gen->type();
  item->smart_playlist_data = gen->Save();
  item->ChangedNotify();
}