Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 1998-2006 George Tzanetakis <gtzan@cs.uvic.ca> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #include "PeakPeriods2BPM.h" 00020 #include "../common_source.h" 00021 00022 00023 using std::ostringstream; 00024 using namespace Marsyas; 00025 00026 PeakPeriods2BPM::PeakPeriods2BPM(mrs_string name):MarSystem("PeakPeriods2BPM",name) 00027 { 00028 addControls(); 00029 } 00030 00031 00032 PeakPeriods2BPM::~PeakPeriods2BPM() 00033 { 00034 } 00035 00036 00037 void 00038 PeakPeriods2BPM::addControls() 00039 { 00040 addctrl("mrs_real/factor", 1.0); 00041 } 00042 00043 MarSystem* 00044 PeakPeriods2BPM::clone() const 00045 { 00046 return new PeakPeriods2BPM(*this); 00047 } 00048 00049 void 00050 PeakPeriods2BPM::myUpdate(MarControlPtr sender) 00051 { 00052 MRSDIAG("PeakPeriods2BPM.cpp - PeakPeriods2BPM:myUpdate"); 00053 00054 // setctrl("mrs_natural/onSamples", getctrl("mrs_natural/inSamples")); 00055 // setctrl("mrs_natural/onObservations", getctrl("mrs_natural/inObservations")); 00056 // setctrl("mrs_real/osrate", getctrl("mrs_real/israte")); 00057 MarSystem::myUpdate(sender); 00058 00059 srate_ = getctrl("mrs_real/israte")->to<mrs_real>(); 00060 00061 } 00062 00063 void 00064 PeakPeriods2BPM::myProcess(realvec& in, realvec& out) 00065 { 00066 mrs_natural t,o; 00067 //checkFlow(in,out); 00068 factor_ = getctrl("mrs_real/factor")->to<mrs_real>(); 00069 factor_ = 4.0; 00070 00071 for (o=0; o < inObservations_; o++) 00072 for (t = 0; t < inSamples_/2; t++) 00073 { 00074 out(o,2*t) = in(o,2*t); 00075 // out(o,2*t+1) = (mrs_real)(srate_ * 60.0 / in(o, 2*t+1)); 00076 out(o,2*t+1) = (mrs_real)(srate_ * 60.0 * factor_ / in(o, 2*t+1)); 00077 // cout << in(o,2*t+1) << "-" << out(o,2*t+1) << endl; 00078 } 00079 00080 } 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090