Revision 23:633ec097fa56 BeatRootVampPlugin.cpp

View differences:

BeatRootVampPlugin.cpp
24 24
BeatRootVampPlugin::BeatRootVampPlugin(float inputSampleRate) :
25 25
    Plugin(inputSampleRate)
26 26
{
27
    m_processor = new BeatRootProcessor(inputSampleRate);
27
    m_processor = new BeatRootProcessor(inputSampleRate, AgentParameters());
28 28
}
29 29

  
30 30
BeatRootVampPlugin::~BeatRootVampPlugin()
......
104 104
BeatRootVampPlugin::getParameterDescriptors() const
105 105
{
106 106
    ParameterList list;
107

  
108
    ParameterDescriptor desc;
109

  
110
    double postMarginFactor;
111

  
112
    /** The maximum amount by which a beat can be earlier than the
113
     *  predicted beat time, expressed as a fraction of the beat
114
     *  period. */
115
    double preMarginFactor;
116

  
117
    /** The maximum allowed deviation from the initial tempo,
118
     * expressed as a fraction of the initial beat period. */
119
    double maxChange;
120

  
121
    /** The default value of expiryTime, which is the time (in
122
     *  seconds) after which an Agent that has no Event matching its
123
     *  beat predictions will be destroyed. */
124
    
125
    desc.identifier = "preMarginFactor";
126
    desc.name = "Pre-Margin Factor";
127
    desc.description = "The maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period.";
128
    desc.minValue = 0;
129
    desc.maxValue = 1;
130
    desc.defaultValue = AgentParameters::DEFAULT_PRE_MARGIN_FACTOR;
131
    desc.isQuantized = false;
132
    list.push_back(desc);
133
    
134
    desc.identifier = "postMarginFactor";
135
    desc.name = "Post-Margin Factor";
136
    desc.description = "The maximum amount by which a beat can be later than the predicted beat time, expressed as a fraction of the beat period.";
137
    desc.minValue = 0;
138
    desc.maxValue = 1;
139
    desc.defaultValue = AgentParameters::DEFAULT_POST_MARGIN_FACTOR;
140
    desc.isQuantized = false;
141
    list.push_back(desc);
142
    
143
    desc.identifier = "maxChange";
144
    desc.name = "Maximum Change";
145
    desc.description = "The maximum allowed deviation from the initial tempo, expressed as a fraction of the initial beat period.";
146
    desc.minValue = 0;
147
    desc.maxValue = 1;
148
    desc.defaultValue = AgentParameters::DEFAULT_MAX_CHANGE;
149
    desc.isQuantized = false;
150
    list.push_back(desc);
151
    
152
    desc.identifier = "expiryTime";
153
    desc.name = "Expiry Time";
154
    desc.description = "The default value of expiryTime, which is the time (in seconds) after which an Agent that has no Event matching its beat predictions will be destroyed.";
155
    desc.minValue = 2;
156
    desc.maxValue = 120;
157
    desc.defaultValue = AgentParameters::DEFAULT_EXPIRY_TIME;
158
    desc.isQuantized = false;
159
    list.push_back(desc);
160

  
161
    // Simon says...
162

  
163
    // These are the parameters that should be exposed (Agent.cpp):
164

  
165
    // If Pop, both margins should be lower (0.1).  If classical
166
    // music, post margin can be increased
167
    //
168
    // double Agent::POST_MARGIN_FACTOR = 0.3;
169
    // double Agent::PRE_MARGIN_FACTOR = 0.15;
170
    //
171
    // Max Change tells us how much tempo can change - so for
172
    // classical we should make it higher
173
    // 
174
    // double Agent::MAX_CHANGE = 0.2;
175
    // 
176
    // The EXPIRY TIME default should be defaulted to 100 (usual cause
177
    // of agents dying....)  it should also be exposed in order to
178
    // troubleshoot eventual problems in songs with big silences in
179
    // the beggining/end.
180
    // 
181
    // const double Agent::DEFAULT_EXPIRY_TIME = 10.0;
182

  
107 183
    return list;
108 184
}
109 185

  
110 186
float
111 187
BeatRootVampPlugin::getParameter(string identifier) const
112 188
{
189
    if (identifier == "preMarginFactor") {
190
        return m_parameters.preMarginFactor;
191
    } else if (identifier == "postMarginFactor") {
192
        return m_parameters.postMarginFactor;
193
    } else if (identifier == "maxChange") {
194
        return m_parameters.maxChange;
195
    } else if (identifier == "expiryTime") {
196
        return m_parameters.expiryTime;
197
    }
198
    
113 199
    return 0;
114 200
}
115 201

  
116 202
void
117 203
BeatRootVampPlugin::setParameter(string identifier, float value) 
118 204
{
205
    if (identifier == "preMarginFactor") {
206
        m_parameters.preMarginFactor = value;
207
    } else if (identifier == "postMarginFactor") {
208
        m_parameters.postMarginFactor = value;
209
    } else if (identifier == "maxChange") {
210
        m_parameters.maxChange = value;
211
    } else if (identifier == "expiryTime") {
212
        m_parameters.expiryTime = value;
213
    }
119 214
}
120 215

  
121 216
BeatRootVampPlugin::ProgramList
......
187 282
	return false;
188 283
    }
189 284

  
190
    m_processor->reset();
285
    // Delete the processor that was created with default parameters
286
    // and used to determine the expected step and block size; replace
287
    // with one using the actual parameters we have
288
    delete m_processor;
289
    m_processor = new BeatRootProcessor(m_inputSampleRate, m_parameters);
191 290

  
192 291
    return true;
193 292
}

Also available in: Unified diff