Пример #1
0
void Resonate :: controlChange(int number, StkFloat value)
{
    StkFloat norm = value * ONE_OVER_128;
    if ( norm < 0 ) {
        norm = 0.0;
        errorString_ << "Resonate::controlChange: control value less than zero ... setting to zero!";
        handleError( StkError::WARNING );
    }
    else if ( norm > 1.0 ) {
        norm = 1.0;
        errorString_ << "Resonate::controlChange: control value greater than 128.0 ... setting to 128.0!";
        handleError( StkError::WARNING );
    }

    if (number == 2) // 2
        setResonance( norm * Stk::sampleRate() * 0.5, poleRadius_ );
    else if (number == 4) // 4
        setResonance( poleFrequency_, norm*0.9999 );
    else if (number == 11) // 11
        this->setNotch( norm * Stk::sampleRate() * 0.5, zeroRadius_ );
    else if (number == 1)
        this->setNotch( zeroFrequency_, norm );
    else if (number == __SK_AfterTouch_Cont_) // 128
        adsr_.setTarget( norm );
    else {
        errorString_ << "Resonate::controlChange: undefined control number (" << number << ")!";
        handleError( StkError::WARNING );
    }

#if defined(_STK_DEBUG_)
    errorString_ << "Resonate::controlChange: number = " << number << ", value = " << value << '.';
    handleError( StkError::DEBUG_WARNING );
#endif
}
Пример #2
0
void Resonate :: controlChange( int number, StkFloat value )
{
#if defined(_STK_DEBUG_)
  if ( Stk::inRange( value, 0.0, 128.0 ) == false ) {
    oStream_ << "Resonate::controlChange: value (" << value << ") is out of range!";
    handleError( StkError::WARNING ); return;
  }
#endif

  StkFloat normalizedValue = value * ONE_OVER_128;
  if (number == 2) // 2
    setResonance( normalizedValue * Stk::sampleRate() * 0.5, poleRadius_ );
  else if (number == 4) // 4
    setResonance( poleFrequency_, normalizedValue * 0.9999 );
  else if (number == 11) // 11
    this->setNotch( normalizedValue * Stk::sampleRate() * 0.5, zeroRadius_ );
  else if (number == 1)
    this->setNotch( zeroFrequency_, normalizedValue );
  else if (number == __SK_AfterTouch_Cont_) // 128
    adsr_.setTarget( normalizedValue );
#if defined(_STK_DEBUG_)
  else {
    oStream_ << "Resonate::controlChange: undefined control number (" << number << ")!";
    handleError( StkError::WARNING );
  }
#endif
}
Пример #3
0
LadderFilter<Type>::LadderFilter()  : state (2)
{
    setSampleRate (Type (1000));    // intentionally setting unrealistic default
                                    // sample rate to catch missing initialisation bugs
    setResonance (Type (0));
    setDrive (Type (1.2));
    setMode (Mode::LPF12);
}
Пример #4
0
 BandPass :: BandPass() : Filter()
 {
     b_.resize( 3, 0.0 );
     a_.resize( 3, 0.0 );
     b_[0] = 1.0;
     a_[0] = 1.0;
     inputs_.resize( 3, 1, 0.0 );
     outputs_.resize( 3, 1, 0.0 );
     setResonance(440, 0.1);
     Stk::addSampleRateAlert( this );
 }
Пример #5
0
void Shakers::controlChange(int number, StkFloat value) {
#if defined(_STK_DEBUG_)
  if (Stk::inRange(value, 0.0, 128.0) == false) {
    oStream_ << "Shakers::controlChange: value (" << value
             << ") is out of range!";
    handleError(StkError::WARNING);
    return;
  }
#endif

  StkFloat normalizedValue = value * ONE_OVER_128;
  if (number == __SK_Breath_ ||
      number == __SK_AfterTouch_Cont_) { // 2 or 128 ... energy
    if (shakerType_ == 19 || shakerType_ == 20) {
      if (lastRatchetValue_ < 0.0)
        ratchetCount_++;
      else
        ratchetCount_ = (int)fabs(value - lastRatchetValue_);
      ratchetDelta_ = baseRatchetDelta_ * ratchetCount_;
      lastRatchetValue_ = (int)value;
    } else {
      shakeEnergy_ += normalizedValue * MAX_SHAKE * 0.1;
      if (shakeEnergy_ > MAX_SHAKE)
        shakeEnergy_ = MAX_SHAKE;
    }
  } else if (number == __SK_ModFrequency_) { // 4 ... decay
    systemDecay_ = baseDecay_ + (2.0 * (normalizedValue - 0.5) * decayScale_ *
                                 (1.0 - baseDecay_));
  } else if (number == __SK_FootControl_) { // 11 ... number of objects
    nObjects_ = (StkFloat)(2.0 * normalizedValue * baseObjects_) + 1.1;
    currentGain_ = log(nObjects_) * baseGain_ / nObjects_;
  } else if (number == __SK_ModWheel_) { // 1 ... resonance frequency
    for (unsigned int i = 0; i < nResonances_; i++) {
      StkFloat temp = baseFrequencies_[i] * pow(4.0, normalizedValue - 0.5);
      setResonance(filters_[i], temp, baseRadii_[i]);
    }
  } else if (number == __SK_ShakerInst_) {           // 1071
    unsigned int type = (unsigned int)(value + 0.5); //  Just to be safe
    this->setType(type);
  }
#if defined(_STK_DEBUG_)
  else {
    oStream_ << "Shakers::controlChange: undefined control number (" << number
             << ")!";
    handleError(StkError::WARNING);
  }
#endif
}
Пример #6
0
void MainWindow::initializeQMLComponent()
{
    QDeclarativeContext *context = m_view->rootContext();

#if defined(Q_WS_MAEMO_5) || defined(QT_NO_OPENGL)
    // Set UI to low performance mode for Maemo5 and Symbian^1. This mainly
    // disables antialiasing on some performance costly elements.
    context->setContextProperty("lowPerf", true);
#else
    context->setContextProperty("lowPerf", false);
#endif

#ifdef Q_OS_SYMBIAN
    context->setContextProperty("sampleFolder", "file:");
#else
    context->setContextProperty("sampleFolder", QString("file:/") +
                                QDir::currentPath());
#endif

#ifdef Q_WS_MAEMO_6
    // Hide the exit button in Harmattan
    context->setContextProperty("exitButtonVisible", false);
#else
    context->setContextProperty("exitButtonVisible", true);
#endif

    m_view->setSource(QUrl("qrc:/qml/Main.qml"));

    // Create Qt settings object to load / store app settings
    m_settings = new QSettings("Nokia", "DJTurntable");

    // Create Qt objects to handle Turntable and Drum machine
    m_turntable = new Turntable(m_settings, this);
    m_drumMachine = new DrumMachine(m_settings, this);
    m_turntable->addAudioSource(m_drumMachine);

    // Find out the interesting Qt objects of the QML elements
    QObject *turntableQML = dynamic_cast<QObject*>(m_view->rootObject());
    QObject *sampleSelectorQML =
            m_view->rootObject()->findChild<QObject*>("sampleSelector");
    QObject *drumMachineQML =
            m_view->rootObject()->findChild<QObject*>("drumMachine");

    // If there are errors in QML code and the elements does not exist,
    // they won't be found Qt side either, check existance of the elements.
    if (!turntableQML || !sampleSelectorQML || !drumMachineQML) {
        QMessageBox::warning(NULL, "Warning",
                             "Failed to resolve QML elements in main.cpp");
        return;
    }

    // Turntable connections
    connect(turntableQML, SIGNAL(start()),
            m_turntable, SLOT(start()));
    connect(turntableQML, SIGNAL(stop()),
            m_turntable, SLOT(stop()));
    connect(turntableQML, SIGNAL(diskAimSpeed(QVariant)),
            m_turntable, SLOT(setDiscAimSpeed(QVariant)));
    connect(turntableQML, SIGNAL(diskSpeed(QVariant)),
            m_turntable, SLOT(setDiscSpeed(QVariant)));
    connect(turntableQML, SIGNAL(cutOff(QVariant)),
            m_turntable, SLOT(setCutOff(QVariant)));
    connect(turntableQML, SIGNAL(resonance(QVariant)),
            m_turntable, SLOT(setResonance(QVariant)));
    connect(turntableQML, SIGNAL(seekToPosition(QVariant)),
            m_turntable, SLOT(seekToPosition(QVariant)));
    connect(m_turntable, SIGNAL(audioPosition(QVariant)),
            turntableQML, SLOT(audioPosition(QVariant)));
    connect(m_turntable, SIGNAL(powerOff()),
            turntableQML, SLOT(powerOff()));

    // SampleSelector connections
    connect(sampleSelectorQML, SIGNAL(sampleSelected(QVariant)),
            m_turntable, SLOT(setSample(QVariant)));
    connect(sampleSelectorQML, SIGNAL(defaultSample()),
            m_turntable, SLOT(openDefaultSample()));
    connect(m_turntable, SIGNAL(sampleOpened(QVariant)),
            sampleSelectorQML, SLOT(setCurrentSample(QVariant)));
    connect(m_turntable, SIGNAL(error(QVariant, QVariant)),
            sampleSelectorQML, SLOT(showError(QVariant, QVariant)));

    // DrumMachine connections
    connect(drumMachineQML, SIGNAL(startBeat()),
            m_drumMachine, SLOT(startBeat()));
    connect(drumMachineQML, SIGNAL(stopBeat()),
            m_drumMachine, SLOT(stopBeat()));
    connect(drumMachineQML, SIGNAL(setBeat(QVariant)),
            m_drumMachine, SLOT(setBeat(QVariant)));
    connect(drumMachineQML,
            SIGNAL(drumButtonToggled(QVariant, QVariant, QVariant)),
            m_drumMachine,
            SLOT(drumButtonToggled(QVariant, QVariant, QVariant)));
    connect(drumMachineQML, SIGNAL(drumMachineSpeed(QVariant)),
            m_drumMachine, SLOT(setBeatSpeed(QVariant)));
    connect(m_drumMachine,
            SIGNAL(drumButtonState(QVariant, QVariant, QVariant)),
            drumMachineQML,
            SLOT(setDrumButton(QVariant, QVariant, QVariant)));
    connect(m_drumMachine, SIGNAL(tickChanged(QVariant)),
            drumMachineQML, SLOT(highlightTick(QVariant)));

    // Framework connections
    connect((QObject*)m_view->engine(), SIGNAL(quit()), qApp, SLOT(quit()));

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
#ifndef QT_NO_OPENGL
    // Create Qt accelerometer objects
    m_accelerometer = new QAccelerometer(this);
    m_accelerometerFilter = new AccelerometerFilter;
    // Does not take the ownership of the filter
    m_accelerometer->addFilter(m_accelerometerFilter);

    m_accelerometer->setDataRate(50);

    // Create Qt objects for accessing profile information
    m_deviceInfo = new QSystemDeviceInfo(this);
    m_turntable->profile(m_deviceInfo->currentProfile());

    connect(m_accelerometerFilter, SIGNAL(rotationChanged(QVariant)),
            turntableQML, SLOT(inclination(QVariant)));
    connect(m_deviceInfo,
            SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),
            m_turntable,
            SLOT(profile(QSystemDeviceInfo::Profile)));

    // Begin the measuring of the accelerometer sensor
    m_accelerometer->start();
#endif
#endif

    m_turntable->openLastSample();
    m_drumMachine->setBeat(0);
}
Пример #7
0
void Shakers::setType(int type) {
  if (shakerType_ == type)
    return;
  varyFactor_ = 0.0;
  shakerType_ = type;
  if (type == 1) { // Cabasa
    nResonances_ = CABASA_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = CABASA_NUM_BEADS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = CABASA_RADII[i];
      baseFrequencies_[i] = CABASA_FREQUENCIES[i];
      filters_[i].gain = CABASA_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = CABASA_SYSTEM_DECAY;
    baseGain_ = CABASA_GAIN;
    soundDecay_ = CABASA_SOUND_DECAY;
    decayScale_ = 0.97;
    setEqualization(1.0, -1.0, 0.0);
  } else if (type == 2) { // Sekere
    nResonances_ = SEKERE_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = SEKERE_NUM_BEANS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = SEKERE_RADII[i];
      baseFrequencies_[i] = SEKERE_FREQUENCIES[i];
      filters_[i].gain = SEKERE_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = SEKERE_SYSTEM_DECAY;
    baseGain_ = SEKERE_GAIN;
    soundDecay_ = SEKERE_SOUND_DECAY;
    decayScale_ = 0.94;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type == 3) { // Tambourine
    nResonances_ = TAMBOURINE_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = TAMBOURINE_NUM_TIMBRELS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = TAMBOURINE_RADII[i];
      baseFrequencies_[i] = TAMBOURINE_FREQUENCIES[i];
      filters_[i].gain = TAMBOURINE_GAINS[i];
      doVaryFrequency_[i] = true;
    }
    doVaryFrequency_[0] = false;
    baseDecay_ = TAMBOURINE_SYSTEM_DECAY;
    baseGain_ = TAMBOURINE_GAIN;
    soundDecay_ = TAMBOURINE_SOUND_DECAY;
    decayScale_ = 0.95;
    varyFactor_ = 0.05;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type == 4) { // Sleighbells
    nResonances_ = SLEIGH_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = SLEIGH_NUM_BELLS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = SLEIGH_RADII[i];
      baseFrequencies_[i] = SLEIGH_FREQUENCIES[i];
      filters_[i].gain = SLEIGH_GAINS[i];
      doVaryFrequency_[i] = true;
    }
    baseDecay_ = SLEIGH_SYSTEM_DECAY;
    baseGain_ = SLEIGH_GAIN;
    soundDecay_ = SLEIGH_SOUND_DECAY;
    decayScale_ = 0.9;
    varyFactor_ = 0.03;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type == 5) { // Bamboo chimes
    nResonances_ = BAMBOO_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = BAMBOO_NUM_TUBES;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = BAMBOO_RADII[i];
      baseFrequencies_[i] = BAMBOO_FREQUENCIES[i];
      filters_[i].gain = BAMBOO_GAINS[i];
      doVaryFrequency_[i] = true;
    }
    baseDecay_ = BAMBOO_SYSTEM_DECAY;
    baseGain_ = BAMBOO_GAIN;
    soundDecay_ = BAMBOO_SOUND_DECAY;
    decayScale_ = 0.7;
    varyFactor_ = 0.2;
    setEqualization(1.0, 0.0, 0.0);
  } else if (type == 6) { // Sandpaper
    nResonances_ = SANDPAPER_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = SANDPAPER_NUM_GRAINS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = SANDPAPER_RADII[i];
      baseFrequencies_[i] = SANDPAPER_FREQUENCIES[i];
      filters_[i].gain = SANDPAPER_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = SANDPAPER_SYSTEM_DECAY;
    baseGain_ = SANDPAPER_GAIN;
    soundDecay_ = SANDPAPER_SOUND_DECAY;
    decayScale_ = 0.97;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type == 7) { // Cokecan
    nResonances_ = COKECAN_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = COKECAN_NUM_PARTS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = COKECAN_RADII[i];
      baseFrequencies_[i] = COKECAN_FREQUENCIES[i];
      filters_[i].gain = COKECAN_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = COKECAN_SYSTEM_DECAY;
    baseGain_ = COKECAN_GAIN;
    soundDecay_ = COKECAN_SOUND_DECAY;
    decayScale_ = 0.95;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type == 8) { // Stix1
    nResonances_ = STIX1_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = STIX1_NUM_BEANS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = STIX1_RADII[i];
      baseFrequencies_[i] = STIX1_FREQUENCIES[i];
      filters_[i].gain = STIX1_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = STIX1_SYSTEM_DECAY;
    baseGain_ = STIX1_GAIN;
    soundDecay_ = STIX1_SOUND_DECAY;
    decayScale_ = 0.96;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type == 9) { // Crunch1
    nResonances_ = CRUNCH1_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = CRUNCH1_NUM_BEADS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = CRUNCH1_RADII[i];
      baseFrequencies_[i] = CRUNCH1_FREQUENCIES[i];
      filters_[i].gain = CRUNCH1_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = CRUNCH1_SYSTEM_DECAY;
    baseGain_ = CRUNCH1_GAIN;
    soundDecay_ = CRUNCH1_SOUND_DECAY;
    decayScale_ = 0.96;
    setEqualization(1.0, -1.0, 0.0);
  } else if (type == 10) { // Big Rocks
    nResonances_ = BIGROCKS_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = BIGROCKS_NUM_PARTS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = BIGROCKS_RADII[i];
      baseFrequencies_[i] = BIGROCKS_FREQUENCIES[i];
      filters_[i].gain = BIGROCKS_GAINS[i];
      doVaryFrequency_[i] = true;
    }
    baseDecay_ = BIGROCKS_SYSTEM_DECAY;
    baseGain_ = BIGROCKS_GAIN;
    soundDecay_ = BIGROCKS_SOUND_DECAY;
    decayScale_ = 0.95;
    varyFactor_ = 0.11;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type == 11) { // Little Rocks
    nResonances_ = LITTLEROCKS_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = LITTLEROCKS_NUM_PARTS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = LITTLEROCKS_RADII[i];
      baseFrequencies_[i] = LITTLEROCKS_FREQUENCIES[i];
      filters_[i].gain = LITTLEROCKS_GAINS[i];
      doVaryFrequency_[i] = true;
    }
    baseDecay_ = LITTLEROCKS_SYSTEM_DECAY;
    baseGain_ = LITTLEROCKS_GAIN;
    soundDecay_ = LITTLEROCKS_SOUND_DECAY;
    decayScale_ = 0.95;
    varyFactor_ = 0.18;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type > 11 && type < 19) { // Nextmug
    nResonances_ = NEXTMUG_RESONANCES;
    if (type > 12) // mug + coin
      nResonances_ += COIN_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = NEXTMUG_NUM_PARTS;
    for (int i = 0; i < NEXTMUG_RESONANCES; i++) {
      baseRadii_[i] = NEXTMUG_RADII[i];
      baseFrequencies_[i] = NEXTMUG_FREQUENCIES[i];
      filters_[i].gain = NEXTMUG_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = NEXTMUG_SYSTEM_DECAY;
    baseGain_ = NEXTMUG_GAIN;
    soundDecay_ = NEXTMUG_SOUND_DECAY;
    decayScale_ = 0.95;
    setEqualization(1.0, 0.0, -1.0);

    // Add coins
    if (type == 13) { // Mug + Penny
      for (int i = 0; i < COIN_RESONANCES; i++) {
        baseRadii_[i + NEXTMUG_RESONANCES] = PENNY_RADII[i];
        baseFrequencies_[i + NEXTMUG_RESONANCES] = PENNY_FREQUENCIES[i];
        filters_[i + NEXTMUG_RESONANCES].gain = PENNY_GAINS[i];
        doVaryFrequency_[i + NEXTMUG_RESONANCES] = false;
      }
    } else if (type == 14) { // Mug + Nickel
      for (int i = 0; i < COIN_RESONANCES; i++) {
        baseRadii_[i + NEXTMUG_RESONANCES] = NICKEL_RADII[i];
        baseFrequencies_[i + NEXTMUG_RESONANCES] = NICKEL_FREQUENCIES[i];
        filters_[i + NEXTMUG_RESONANCES].gain = NICKEL_GAINS[i];
        doVaryFrequency_[i + NEXTMUG_RESONANCES] = false;
      }
    } else if (type == 15) { // Mug + Dime
      for (int i = 0; i < COIN_RESONANCES; i++) {
        baseRadii_[i + NEXTMUG_RESONANCES] = DIME_RADII[i];
        baseFrequencies_[i + NEXTMUG_RESONANCES] = DIME_FREQUENCIES[i];
        filters_[i + NEXTMUG_RESONANCES].gain = DIME_GAINS[i];
        doVaryFrequency_[i + NEXTMUG_RESONANCES] = false;
      }
    } else if (type == 16) { // Mug + Quarter
      for (int i = 0; i < COIN_RESONANCES; i++) {
        baseRadii_[i + NEXTMUG_RESONANCES] = QUARTER_RADII[i];
        baseFrequencies_[i + NEXTMUG_RESONANCES] = QUARTER_FREQUENCIES[i];
        filters_[i + NEXTMUG_RESONANCES].gain = QUARTER_GAINS[i];
        doVaryFrequency_[i + NEXTMUG_RESONANCES] = false;
      }
    } else if (type == 17) { // Mug + Franc
      for (int i = 0; i < COIN_RESONANCES; i++) {
        baseRadii_[i + NEXTMUG_RESONANCES] = FRANC_RADII[i];
        baseFrequencies_[i + NEXTMUG_RESONANCES] = FRANC_FREQUENCIES[i];
        filters_[i + NEXTMUG_RESONANCES].gain = FRANC_GAINS[i];
        doVaryFrequency_[i + NEXTMUG_RESONANCES] = false;
      }
    } else if (type == 18) { // Mug + Peso
      for (int i = 0; i < COIN_RESONANCES; i++) {
        baseRadii_[i + NEXTMUG_RESONANCES] = PESO_RADII[i];
        baseFrequencies_[i + NEXTMUG_RESONANCES] = PESO_FREQUENCIES[i];
        filters_[i + NEXTMUG_RESONANCES].gain = PESO_GAINS[i];
        doVaryFrequency_[i + NEXTMUG_RESONANCES] = false;
      }
    }
  } else if (type == 19) { // Guiro
    nResonances_ = GUIRO_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = GUIRO_NUM_PARTS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = GUIRO_RADII[i];
      baseFrequencies_[i] = GUIRO_FREQUENCIES[i];
      filters_[i].gain = GUIRO_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseGain_ = GUIRO_GAIN;
    soundDecay_ = GUIRO_SOUND_DECAY;
    ratchetCount_ = 0;
    baseRatchetDelta_ = 0.0001;
    ratchetDelta_ = baseRatchetDelta_;
    lastRatchetValue_ = -1;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type == 20) { // Wrench
    nResonances_ = WRENCH_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = WRENCH_NUM_PARTS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = WRENCH_RADII[i];
      baseFrequencies_[i] = WRENCH_FREQUENCIES[i];
      filters_[i].gain = WRENCH_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseGain_ = WRENCH_GAIN;
    soundDecay_ = WRENCH_SOUND_DECAY;
    ratchetCount_ = 0;
    baseRatchetDelta_ = 0.00015;
    ratchetDelta_ = baseRatchetDelta_;
    lastRatchetValue_ = -1;
    setEqualization(1.0, 0.0, -1.0);
  } else if (type == 21) { // Water Drops
    nResonances_ = WATER_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    tempFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = WATER_NUM_SOURCES;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = WATER_RADII[i];
      baseFrequencies_[i] = WATER_FREQUENCIES[i];
      tempFrequencies_[i] = WATER_FREQUENCIES[i];
      filters_[i].gain = WATER_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = WATER_SYSTEM_DECAY;
    baseGain_ = WATER_GAIN;
    soundDecay_ = WATER_SOUND_DECAY;
    decayScale_ = 0.8;
    setEqualization(-1.0, 0.0, 1.0);
  } else if (type == 22) { // Tuned Bamboo Chimes (Angklung)
    nResonances_ = ANGKLUNG_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = ANGKLUNG_NUM_TUBES;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = ANGKLUNG_RADII[i];
      baseFrequencies_[i] = ANGKLUNG_FREQUENCIES[i];
      filters_[i].gain = ANGKLUNG_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = ANGKLUNG_SYSTEM_DECAY;
    baseGain_ = ANGKLUNG_GAIN;
    soundDecay_ = ANGKLUNG_SOUND_DECAY;
    decayScale_ = 0.7;
    setEqualization(1.0, 0.0, -1.0);
  } else { // Maraca (default)
    shakerType_ = 0;
    nResonances_ = MARACA_RESONANCES;
    filters_.resize(nResonances_);
    baseFrequencies_.resize(nResonances_);
    baseRadii_.resize(nResonances_);
    doVaryFrequency_.resize(nResonances_);
    baseObjects_ = MARACA_NUM_BEANS;
    for (unsigned int i = 0; i < nResonances_; i++) {
      baseRadii_[i] = MARACA_RADII[i];
      baseFrequencies_[i] = MARACA_FREQUENCIES[i];
      filters_[i].gain = MARACA_GAINS[i];
      doVaryFrequency_[i] = false;
    }
    baseDecay_ = MARACA_SYSTEM_DECAY;
    baseGain_ = MARACA_GAIN;
    soundDecay_ = MARACA_SOUND_DECAY;
    decayScale_ = 0.97;
    setEqualization(1.0, -1.0, 0.0);
  }

  // Set common algorithm variables.
  shakeEnergy_ = 0.0;
  sndLevel_ = 0.0;
  nObjects_ = baseObjects_;
  systemDecay_ = baseDecay_;
  currentGain_ = log(nObjects_) * baseGain_ / nObjects_;

  for (unsigned int i = 0; i < nResonances_; i++)
    setResonance(filters_[i], baseFrequencies_[i], baseRadii_[i]);
}
Пример #8
0
Filter::Filter(float f, float m)
{
  setFrequency(f);
  setResonance(m);
}
Пример #9
0
 void BandPass ::setQ( StkFloat _radius){
     setResonance(frequency, _radius);
 }
Пример #10
0
 void BandPass ::setFrequency( StkFloat _frequency){
     setResonance(_frequency, this->q);
 }