当前位置: 首页>>代码示例>>C++>>正文


C++ MarSystem::updctrl方法代码示例

本文整理汇总了C++中MarSystem::updctrl方法的典型用法代码示例。如果您正苦于以下问题:C++ MarSystem::updctrl方法的具体用法?C++ MarSystem::updctrl怎么用?C++ MarSystem::updctrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MarSystem的用法示例。


在下文中一共展示了MarSystem::updctrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sfplayFile

// Play soundfile given by sfName, msys contains the playback
// network of MarSystem objects
void sfplayFile(MarSystem& msys, mrs_natural offset, mrs_natural duration,
                mrs_real start, mrs_real length, mrs_real gain, mrs_real repetitions, string sfName )
{
  msys.updctrl("SoundFileSource/src/mrs_string/filename", sfName);
  mrs_natural nChannels = msys.getctrl("SoundFileSource/src/mrs_natural/nChannels")->to<mrs_natural>();
  mrs_real srate = msys.getctrl("SoundFileSource/src/mrs_real/israte")->to<mrs_real>();

  // playback offset & duration
  offset = (mrs_natural) (start * srate * nChannels);
  duration = (mrs_natural) (length * srate * nChannels);

  // udpate controls
  msys.updctrl("mrs_natural/inSamples", MRS_DEFAULT_SLICE_NSAMPLES);
  msys.updctrl("Gain/gt/mrs_real/gain", gain);
  msys.updctrl("SoundFileSource/src/mrs_natural/pos", offset);

  mrs_natural wc=0;
  mrs_natural samplesPlayed = 0;
  mrs_natural onSamples = msys.getctrl("mrs_natural/onSamples")->to<mrs_natural>();
  // mrs_natural repeatId = 1;

  while (msys.getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>())
  {
    msys.tick();
    wc ++;
    samplesPlayed += onSamples;
  }
  cerr << "Played " << wc << " slices of " << onSamples << " samples" << endl;
}
开发者ID:Amos-zq,项目名称:marsyas,代码行数:31,代码来源:sendUDP.cpp

示例2: newMidiInfo

void newMidiInfo()
{
    /*
	  This function describes using the MidiInput object and MarControlPointers 
	  to read midi controls in a loop. The disadvantage of this approach is that
	  MidiINput will only return the last midi value between buffers. Change the 
	  buffer size you would like more precision and throughput for midi messages. 
    */
    MarSystemManager mng;
    MarSystem* series = mng.create("Series", "series");
    series->addMarSystem(mng.create("AudioSource","src"));
    series->addMarSystem(mng.create("MidiInput","midiin"));

    series->updctrl("mrs_real/israte", 44100.0);
    series->updctrl("mrs_real/osrate", 44100.0);
    // to change how often marsyas grabs messages change the buffersize
    series->updctrl("AudioSource/src/mrs_natural/bufferSize", 64);
    series->updctrl("AudioSource/src/mrs_bool/initAudio",true);
    series->updctrl("MidiInput/midiin/mrs_bool/initmidi",true);

    MarControlPtr b1 = series->getctrl("MidiInput/midiin/mrs_natural/byte1");
    MarControlPtr b2 = series->getctrl("MidiInput/midiin/mrs_natural/byte2");
    MarControlPtr b3 = series->getctrl("MidiInput/midiin/mrs_natural/byte3");

    while(1) 
    {  
        const  mrs_natural& byte1 = b1->to<mrs_natural>(); 
        const  mrs_natural& byte2 = b2->to<mrs_natural>();   
        const  mrs_natural& byte3 = b3->to<mrs_natural>(); 

        std::cout <<  "Byte 1: " << byte1 << "    Byte 2: " << byte2 << "    Byte 3: " << byte3 << endl;

        series->tick();
    }
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:35,代码来源:midiTest.cpp

示例3: run

// thread code
void* run(void * arg)
{
  
  thread_data* data = (thread_data*) arg;

  MarSystemManager mng;
  NetworkTCPSource* src = new NetworkTCPSource("src");
  
  MarSystem* featureNetwork = mng.create("Series", "featureNetwork");
  featureNetwork->addMarSystem(src);
  featureNetwork->addMarSystem(mng.create("AudioSink", "sink"));
  // featureNetwork->addMarSystem(mng.create("PlotSink", "psink"));
  
  featureNetwork->updctrl("NetworkTCPSource/src/mrs_natural/dataPort", data->dataPort);
  featureNetwork->updctrl("NetworkTCPSource/src/mrs_natural/controlsPort", data->controlsPort);

  featureNetwork->linkctrl("mrs_bool/hasData", "NetworkTCPSource/src/mrs_bool/hasData");
  
  src->refresh();
  
  mrs_natural wc = 0;
  
  mrs_real* controls = 0;
  
  mrs_natural onSamples = featureNetwork->getctrl("mrs_natural/onSamples")->to<mrs_natural>();
  
  
  // start the network 
  while ( featureNetwork->getctrl("mrs_bool/hasData")->to<mrs_bool>() ) {

	try {
		
		controls = featureNetwork->recvControls();	
      		if ( controls != 0 ) {
			
			// get some reference controls, so if they have changed we update them
			mrs_natural inSamples = featureNetwork->getctrl("mrs_natural/inSamples")->to<mrs_natural>();
			mrs_natural inObservations = featureNetwork->getctrl("mrs_natural/inObservations")->to<mrs_natural>();
			mrs_real israte = featureNetwork->getctrl("mrs_real/israte")->to<mrs_real>();
			
			if ( (mrs_natural)controls[1] != inSamples || (mrs_natural)controls[2] != inObservations 
					|| controls[3] != israte ) {
			
				featureNetwork->updctrl("mrs_natural/inSamples", (mrs_natural)controls[1]);
				featureNetwork->updctrl("mrs_natural/inObservations", (mrs_natural)controls[2]);
				featureNetwork->updctrl("mrs_real/israte", controls[3]);
			}
      		}
		
		featureNetwork->tick(); // everything happens here 
	} catch ( SocketException e ) {
  		cerr << "Played " << wc << " slices of " << onSamples << " samples" << endl;
		pthread_exit(NULL);
	}
 	wc++;
   }
  cout << "played - " << wc << " slices of " << onSamples << " samples" << endl;
 
  pthread_exit( NULL );
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:61,代码来源:collector.cpp

示例4: execute

bool MslCommandRun::execute()
{
  MarSystem* msys;

  if ( workingSet.find(name) != workingSet.end() ) {
    msys = (MarSystem *)workingSet[name];
  } else {
    cout << "Cannot find MarSystem: " << name << endl;
    return false;
  }

  mrs_natural wc=0;
  mrs_natural samplesPlayed = 0;
  mrs_natural onSamples = msys->getctrl("mrs_natural/onSamples")->to<mrs_natural>();

  mrs_real* controls = 0;

  while (true) {

    try {

      controls = msys->recvControls();

      if ( controls != 0 ) {

        // get some reference controls, so if they have changed we update them
        mrs_natural inSamples = msys->getctrl("mrs_natural/inSamples")->to<mrs_natural>();
        mrs_natural inObservations = msys->getctrl("mrs_natural/inObservations")->to<mrs_natural>();
        mrs_real israte = msys->getctrl("mrs_real/israte")->to<mrs_real>();

        if ( (mrs_natural)controls[1] != inSamples || (mrs_natural)controls[2] != inObservations
             || controls[3] != israte ) {

          msys->updctrl("mrs_natural/inSamples",(mrs_natural) controls[1]);
          msys->updctrl("mrs_natural/inObservations", (mrs_natural)controls[2]);
          msys->updctrl("mrs_real/israte", controls[3]);
        }
      }

      msys->tick();
    }
    catch( SocketException e ) {
      cout << "Played " << wc << " slices of " << onSamples << " samples" << endl;
      exit(1);
    }

    wc ++;

    if ( !msys->getctrl("mrs_bool/hasData")->isTrue() ) {
      break;
    }
    samplesPlayed += onSamples;

  } // while

  cout << "Played " << wc << " slices of " << onSamples << " samples" << endl;
  return true;
}
开发者ID:Amos-zq,项目名称:marsyas,代码行数:58,代码来源:MslModel.cpp

示例5: Plugin

MarsyasBExtractRolloff::MarsyasBExtractRolloff(float inputSampleRate) :
  Plugin(inputSampleRate),
  m_stepSize(0),
  m_previousSample(0.f),
  m_network(0)
{
  MarSystemManager mng;
  // Overall extraction and classification network
  m_network = mng.create("Series", "mainNetwork");

  // Build the overall feature calculation network
  MarSystem *featureNetwork = mng.create("Series", "featureNetwork");

  // Add a realvec as the source
  featureNetwork->addMarSystem(mng.create("RealvecSource", "src"));

  // Convert the data to mono
  featureNetwork->addMarSystem(mng.create("Stereo2Mono", "m2s"));

  // Setup the feature extractor
  MarSystem* featExtractor = mng.create("TimbreFeatures", "featExtractor");
  featExtractor->updctrl("mrs_string/enableSPChild", "Rolloff/rlf");
  featureNetwork->addMarSystem(featExtractor);

  // Add the featureNetwork to the main network
  m_network->addMarSystem(featureNetwork);
}
开发者ID:Amos-zq,项目名称:marsyas,代码行数:27,代码来源:MarsyasBExtractRolloff.cpp

示例6:

void
basic_delay(string infile, string outfile)
{
	MarSystem* pnet = mng.create("Series", "pnet");
	addSource( pnet, infile );
	pnet->addMarSystem(mng.create("Delay", "delay"));
	pnet->updctrl("Delay/delay/mrs_natural/delaySamples", 16);
	pnet->updctrl("Delay/delay/mrs_real/feedback", (mrs_real) 0.5);
	addDest( pnet, outfile);

	while (pnet->getctrl("mrs_bool/hasData")->to<mrs_bool>())
	{
		pnet->tick();
	}
	delete pnet;
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:16,代码来源:basicChecks.cpp

示例7: while

// take advantage of MarSystemManager 
void 
tempotest_sfplay(string sfName)
{
    cout << "Playing " << sfName << endl; 

    MarSystemManager mng;

    // Create a series Composite 
    MarSystem* series = mng.create("Series", "series");
    series->addMarSystem(mng.create("SoundFileSource", "src"));
    series->addMarSystem(mng.create("AudioSink", "dest"));

    // only update controls from Composite level 
    series->updctrl("mrs_natural/inSamples", 128);
    series->updctrl("SoundFileSource/src/mrs_string/filename", sfName);

    while (series->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>())
        series->tick();

    delete series;
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:22,代码来源:midiTest.cpp

示例8: centroidToTxt

	void centroidToTxt(string sfName1) {
		cout << "Toy with centroid " << sfName1 << endl;
		MarSystemManager mng;

		MarSystem* net = mng.create("Series/net");
		net->addMarSystem(mng.create("SoundFileSource/src"));
		net->addMarSystem(mng.create("Windowing/ham"));
		net->addMarSystem(mng.create("Spectrum/spk"));
		net->addMarSystem(mng.create("PowerSpectrum/pspk"));
		net->addMarSystem(mng.create("Centroid/cntrd"));
		net->addMarSystem(mng.create("Memory/mem"));
		net->addMarSystem(mng.create("Mean/mean"));
		net->linkctrl("mrs_string/filename", "SoundFileSource/src/mrs_string/filename");
		net->updctrl("mrs_string/filename", sfName1);

		mrs_real val = 0.0;

		ofstream ofs;
		ofs.open("centroid.mpl");
		ofs << *net << endl;
		ofs.close();

		ofstream text;
		text.open("centroid.txt");


		while (net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>())
		{
			net->tick();
			const mrs_realvec& src_data =
			net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
			val = src_data(0,0);
			text << val << endl;
			//cout << val << endl;
		}
		text.close();
	}
开发者ID:8Strings,项目名称:MX-Ray,代码行数:37,代码来源:MX-Mars.cpp

示例9: main

int main(int argc, const char** argv)
{
	if (argc < 3) {
		cout << "Usage: " << argv[0] << " soundfile outputfile" << endl;
		return 1;
	}
	
	MarSystemManager mng;
	
//------------------ Feature Network ------------------------------

	// Decode the file, downmix to mono, and downsample
	MarSystem *fnet = mng.create("Series", "fnet");
	fnet->addMarSystem(mng.create("SoundFileSource", "src"));
	fnet->addMarSystem(mng.create("DownSampler", "ds"));
	fnet->addMarSystem(mng.create("Stereo2Mono", "s2m"));
	
	// Create the feature extractor
	fnet->addMarSystem(mng.create("TimbreFeatures", "tf"));
	fnet->updctrl("TimbreFeatures/tf/mrs_string/enableTDChild", "ZeroCrossings/zcrs");
	fnet->updctrl("TimbreFeatures/tf/mrs_string/enableSPChild", "MFCC/mfcc");
	fnet->updctrl("TimbreFeatures/tf/mrs_string/enableSPChild", "Centroid/cntrd");
	fnet->updctrl("TimbreFeatures/tf/mrs_string/enableSPChild", "Flux/flux");
	fnet->updctrl("TimbreFeatures/tf/mrs_string/enableSPChild", "Rolloff/rlf");
	
	// Add the texture statistics
	fnet->addMarSystem(mng.create("TextureStats", "tStats"));

//------------------- Set Parameters ------------------------------
	
	// Set the texture memory size to a 1-second window (22 analysis frames)
	fnet->updctrl("TextureStats/tStats/mrs_natural/memSize", 22);

	// Set the file name
	fnet->updctrl("SoundFileSource/src/mrs_string/filename", argv[1]);
	
	// Set the sample rate to 11250 Hz
	mrs_natural factor = round(fnet->getctrl("SoundFileSource/src/mrs_real/osrate")
		->to<mrs_real>()/11250.0);
	fnet->updctrl("DownSampler/ds/mrs_natural/factor", factor);
	
	// Set the window to 1024 samples at 11250 Hz
	// Should be able to set with simply TimbreFeatures/tf/mrs_natural/winSize,
	// but that doesn't seem to work
	fnet->updctrl("TimbreFeatures/tf/Series/timeDomain/ShiftInput/si/mrs_natural/winSize", 1024);
	fnet->updctrl("TimbreFeatures/tf/Series/spectralShape/ShiftInput/si/mrs_natural/winSize", 1024);
	fnet->updctrl("TimbreFeatures/tf/Series/lpcFeatures/ShiftInput/si/mrs_natural/winSize", 1024);
	
	// Find the length of the song
	mrs_natural slength = fnet->getctrl("SoundFileSource/src/mrs_natural/size")->to<mrs_natural>();
	
	// Find the number of samples resulting in a whole number of analysis windows by truncating
	mrs_natural numsamps = (mrs_natural)(((30*11250.0*factor)/512)*512);

	// Shift the start over so that the duration is in the middle
	mrs_natural start = (slength - numsamps)/2;

	fnet->updctrl("SoundFileSource/src/mrs_natural/start", start);
	fnet->updctrl("SoundFileSource/src/mrs_natural/duration", numsamps);

// ----------------- Accumulator ---------------------------------

	// Accumulate over the entire song
	MarSystem *acc = mng.create("Accumulator", "acc");
		
	// nTimes is measured in number of analysis windows
	acc->updctrl("mrs_natural/nTimes", (mrs_natural)((30*11250.0)/512));

//------------------ Song Statistics -----------------------------
	// Fanout and calculate mean and standard deviation
	MarSystem *sstats = mng.create("Fanout", "sstats");
	sstats->addMarSystem(mng.create("Mean", "smn"));
	sstats->addMarSystem(mng.create("StandardDeviation", "sstd"));

// ----------------- Top Level Network Wrapper -------------------
	
	// (src->downmix->downsample->features->texture stats)
	// --->accumulator->song stats->output
	MarSystem *tnet = mng.create("Series", "tnet");
	acc->addMarSystem(fnet);
	tnet->addMarSystem(acc);
	tnet->addMarSystem(sstats);
	
	// set the hop size to 512 (needs to be set for the top-level network)
	tnet->updctrl("mrs_natural/inSamples", factor*512);

	try {
		// Should only need to tick once
		tnet->tick();
	} catch (int i)
	{
		cout << "Error analyzing file" << endl;
		return 1;
	}

	realvec result = tnet->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();

	try {
		result.normMaxMin();
		result.write(argv[2]);
//.........这里部分代码省略.........
开发者ID:dinesh,项目名称:reccomen,代码行数:101,代码来源:fextract.cpp

示例10: play

// Play soundfile given by sfName, playbacknet contains the playback 
// network of MarSystem objects 
void play(mrs_real gain, string outName)
{

  NetworkUDPSource* netSrc = new NetworkUDPSource("netSrc");
  
  // update controls if they are passed on cmd line...
  if ( port != 0 ) {
  	netSrc->updctrl("mrs_natural/port", port);
  }
  
  
  // Output destination is either audio or soundfile 
  MarSystem *dest;
  if (outName == EMPTYSTRING)
    dest = new AudioSink("dest");
  else 			
    {
      dest = new AuFileSink("dest");
      dest->updctrl("mrs_string/filename", outName);      
    }

  cout << "Creating playback network..." << endl;
  
  MarSystemManager mn;
  Series playbacknet("playbacknet");
  playbacknet.addMarSystem(netSrc);
  playbacknet.addMarSystem(mn.create("Gain", "gt"));
  playbacknet.addMarSystem(dest);
  
  // output network description to cout  
  cout << playbacknet << endl;      
  
  // udpate controls
  playbacknet.updctrl("mrs_natural/inSamples", MRS_DEFAULT_SLICE_NSAMPLES);
  playbacknet.updctrl("Gain/gt/mrs_real/gain", gain);
  
  // may want to update this as control data from networksource...
  if (outName == EMPTYSTRING) 
    playbacknet.updctrl("AudioSink/dest/mrs_natural/nChannels", 1);
  else 
    playbacknet.updctrl("AuFileSink/dest/mrs_natural/nChannels", 1);
	
  mrs_natural wc=0;
  mrs_natural samplesPlayed = 0;
  mrs_natural onSamples = playbacknet.getctrl("mrs_natural/onSamples")->to<mrs_natural>();
  // mrs_natural repeatId = 1;
  
  netSrc->refresh();
  
  while (true) 
  {
  	try {
  	  playbacknet.tick();
  	  if ( !showClient ) {
  	  	cout << "Receiving from: " << netSrc->getClientAddr() << endl;
  	  	showClient = true;
  	  }
  	  
  	}
  	catch( SocketException e ) {
  	  cerr << "Played " << wc << " slices of " << onSamples << " samples" << endl;	
  	  wc = onSamples = 0;
  	  exit(1);
  	} 
  	wc ++;
    samplesPlayed += onSamples;
  }
  
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:71,代码来源:recvUDP.cpp

示例11: extractBpm

	void extractBpm(string filename) {
		cout << "BPM extractor" << endl;
		MarSystemManager mng;
		MarSystem* blackbox = mng.create("Series", "blackbox");
		blackbox->addMarSystem(mng.create("SoundFileSource", "src"));

		/**
		 * Linkaggio dei controlli: SoundSource
		 */
		blackbox->linkctrl("mrs_string/filename", "SoundFileSource/src/mrs_string/filename");
		blackbox->linkctrl("mrs_string/labelNames", "SoundFileSource/src/mrs_string/labelNames");
		blackbox->updctrl("mrs_string/filename", filename);

		/*
		 * Creazione di un file di testo con alcune informazioni sul file:
		 * fname = name of the file courrently analyzed
		 * israte = input sample rate
		 * osrate = output sample rate
		 * duration = duration of the file in seconds
		 * size = number of audio samples contained into the file
		 * label = label for classification use
		 */

		ofstream finfo;
		finfo.open("durata.txt");

		mrs_string fname = blackbox->getctrl("mrs_string/filename")->to<mrs_string>();
		finfo << "Input file name: " << fname << endl;
		mrs_real israte = blackbox->getctrl("mrs_real/israte")->to<mrs_real>();
		finfo << "Input samplerate: " << israte << " Hz" << endl;
		mrs_real osrate = blackbox->getctrl("mrs_real/osrate")->to<mrs_real>();
		finfo << "Output samplerate: " << osrate << " Hz" << endl;
		mrs_real duration = blackbox->getctrl("SoundFileSource/src/mrs_real/duration")->to<mrs_real>();
		finfo << "Duration: " << duration <<  " seconds" << endl;
		mrs_natural size = blackbox->getctrl("SoundFileSource/src/mrs_natural/size")->to<mrs_natural>();
		finfo << "Number of samples of courrent file: " << size << endl;
		mrs_string label = blackbox->getctrl("mrs_string/labelNames")->to<mrs_string>();
		finfo << "Label name: " << label << endl;
		finfo.close();

		ofstream wavelet;
		wavelet.open("waveletbands.txt");
		wavelet << "WAVELET BANDS VALUES" << endl;
		/*
		 * Preparazione per l'estrazione dell'inviluppo del segnale audio
		 */

		//blackbox->addMarSystem(mng.create("WaveletBands", "wavelet"));
		//blackbox->addMarSystem(mng.create("FullWaveRectifier","rectifier"));
		blackbox->addMarSystem(mng.create("AutoCorrelation", "autocorrelation"));
		blackbox->updctrl("AutoCorrelation/autocorrelation/mrs_bool/aliasedOutput", false);
		blackbox->addMarSystem(mng.create("BeatHistogram", "histogram"));

		mrs_real val = 0.0;
		while (blackbox->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>()) {
			blackbox->tick();
			const mrs_realvec& src_data =
			blackbox->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
			val = src_data(0,0);
			wavelet << val << endl;
		}
		wavelet.close();

		delete blackbox;
		cout << "done" << endl;
	}
开发者ID:8Strings,项目名称:MX-Ray,代码行数:66,代码来源:MX-Mars.cpp

示例12: midiBoomChickAnnotate

void midiBoomChickAnnotate(mrs_natural bufferSize, 
						   mrs_natural inputSize, 
						   string backgroundopt)
{

    /* RtMidi* rtmidi = NULL;


       try {
       rtmidi = new RtMidi();
       }
       catch (RtError3 &error) {
       exit(1);
       }
	*/ 

    MarSystemManager mng;
    MarSystem* total = mng.create("Series", "total");

    MarSystem* pnet = mng.create("Series","pnet");
    MarSystem* oscbank = mng.create("Fanout", "oscbank");
    oscbank->addMarSystem(mng.create("SoundFileSource", "src3"));
    oscbank->addMarSystem(mng.create("SoundFileSource", "src4"));

    pnet->addMarSystem(oscbank);
    pnet->addMarSystem(mng.create("Sum", "sum"));
    pnet->addMarSystem(mng.create("SoundFileSink", "dest"));  


    MarSystem* bbank = mng.create("Fanout", "bbank");
    bbank->addMarSystem(pnet);
    if (backgroundopt != EMPTYSTRING) 
        bbank->addMarSystem(mng.create("SoundFileSource", "src5"));


    total->addMarSystem(bbank);
    total->addMarSystem(mng.create("Sum", "tsum"));
    total->addMarSystem(mng.create("AudioSink", "dest"));

    // output file 
    pnet->updctrl("SoundFileSink/dest/mrs_string/filename", "drum.wav");


    int byte2, byte3;
    int channel;
    int type;
    int prev_pitch;

    // bass drum and snare drum sounds 
    pnet->updctrl("Fanout/oscbank/SoundFileSource/src3/mrs_string/filename", "../rawwaves/sd22k.wav");
    pnet->updctrl("Fanout/oscbank/SoundFileSource/src4/mrs_string/filename", "../rawwaves/bd22k.wav");
    if (backgroundopt != EMPTYSTRING) 
        bbank->updctrl("SoundFileSource/src5/mrs_string/filename", backgroundopt);


    total->updctrl("AudioSink/dest/mrs_natural/bufferSize", bufferSize);
    total->updctrl("mrs_natural/inSamples", inputSize);
    pnet->linkctrl("mrs_natural/pos3", "Fanout/oscbank/SoundFileSource/src3/mrs_natural/pos");    
    pnet->linkctrl("mrs_natural/pos4", "Fanout/oscbank/SoundFileSource/src4/mrs_natural/pos");    



    /* while(1) 
       {  
       if (rtmidi->nextMessage() > 0) 
       {
       byte3 = rtmidi->getByteThree();
       byte2 = rtmidi->getByteTwo();
       channel = rtmidi->getChannel();
       type = rtmidi->getType();

	   // STC1000 NoteOn's
	   if ((type == 144) && (byte3 != 0)) 
	   {
	   // rewind the files 
	   if (byte2 == 44) 
	   pnet->updctrl("mrs_natural/pos3", 0);

	   if (byte2 == 53) 
	   pnet->updctrl("mrs_natural/pos4", 0);		

	   }

	   // Radio Drum stick 1
	   if ((type == 160) && (byte2 == 15)) 	  
	   {

	   if ((byte3 >= 40) && 
	   (byte3 <= 100))
	   {
	   pnet->updctrl("mrs_natural/pos3", 0);	
	   }
	   else 
	   {
	   pnet->updctrl("mrs_natural/pos4", 0);	              
	   }
	   }

	   // Radio Drum stick 2 
	   if ((type == 160) && (byte2 == 17)) 	  
//.........这里部分代码省略.........
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:101,代码来源:midiTest.cpp

示例13: PluckLive

//Pluck Karplus Strong Model Plucked.cpp outputs to DAC
void PluckLive(string deviceopt, mrs_real pos, mrs_real fre, mrs_real loz, mrs_real stret)
{



#ifdef MARSYAS_MIDIIO  
    RtMidiIn *midiin = 0;
    std::vector<unsigned char> message;
    double stamp;
    int nBytes;
    int i;

    // initialize RtMidi
    try {
        midiin = new RtMidiIn();
    }
    catch (RtError3 &error) {
        error.printMessage();
        exit(1);
    }

    // find input midi port 
    try {
        midiin->openPort(portopt);
    }
    catch (RtError3 &error) {
        error.printMessage();
        exit(1);

    }
    MarSystemManager mng;
    MarSystem* series = mng.create("Series", "series");


    // create 16 plucked Karplus-Strong strings
    MarSystem* mix  = mng.create("Fanout", "mix");
    for (mrs_natural i = 0; i < 16; i++) 
    {
        ostringstream oss;
        oss << "src" << i;
        mix->addMarSystem(mng.create("Plucked", oss.str()));  
    }

    series->addMarSystem(mix);
    series->addMarSystem(mng.create("Sum", "sum"));
    series->addMarSystem(mng.create("Gain", "gain"));
    series->addMarSystem(mng.create("AudioSink", "dest"));
    series->update();


    series->updctrl("Gain/gain/mrs_real/gain", 0.10);
    series->updctrl("AudioSink/dest/mrs_real/israte", 
					series->getctrl("Fanout/mix/Plucked/src0/mrs_real/osrate"));

    series->updctrl("AudioSink/dest/mrs_natural/bufferSize", 128); 
    series->updctrl("Fanout/mix/Plucked/src0/mrs_real/frequency",fre);
    series->updctrl("Fanout/mix/Plucked/src0/mrs_real/pluckpos",pos);
    series->updctrl("Fanout/mix/Plucked/src0/mrs_real/loss",loz);
    series->updctrl("mrs_natural/inSamples", 64);
    series->update();


    // initially only play one string 
    for (int i=1; i < 16; i++)
    {
        ostringstream oss1;
        oss1 << "Fanout/mix/Plucked/src" 
			 << i << "/mrs_real/nton";
        series->updctrl(oss1.str(), 0.0);      
    }



    mrs_natural t=0;

    int channel, type, byte2, byte3;
    int mes_count = 0;
    mrs_real freq;
    int p0byte3, p1byte3, p2byte3;


    // used to keep track of polyphony
    vector<int> voices;
    for (int i=0; i < 16; i++) 
    {
        voices.push_back(0);
    }




    while(1)
    {

        // for (int i=0; i < 4; i++)
        // {
        stamp = midiin->getMessage( &message );
        // }

//.........这里部分代码省略.........
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:101,代码来源:midiTest.cpp

示例14: recognize

double* recognize(string sfName)
{
	MarSystemManager mng;
	MarSystem* pnet = mng.create("Series", "pnet");
	MarSystem* Fanout1 = mng.create("Fanout","Fanout1");
	MarSystem* Fanout2 = mng.create("Fanout","Fanout2");
	MarSystem* Spec = mng.create("Series", "Spec");
	MarSystem* SerCentroid = mng.create("Series", "SerCentroid");
	MarSystem* SerRolloff = mng.create("Series", "SerRolloff");
	MarSystem* SerFlux = mng.create("Series", "SerFlux");
	MarSystem* SerSpecMean = mng.create("Series", "SerSpecMean");
	MarSystem* SerSpecMed = mng.create("Series", "SerSpecMed");
	//MarSystem* SerMean = mng.create("Series", "SerMean");		//comming same as spectral Mean
	MarSystem* SerStdDev = mng.create("Series", "SerStdDev");
	MarSystem* SerSkew = mng.create("Series", "SerSkew");
	MarSystem* SerKurtosis = mng.create("Series", "SerKurtosis");
	MarSystem* SerPower = mng.create("Series", "SerPower");
	MarSystem* SerAutoCor = mng.create("Series", "SerAutoCor");
	MarSystem* SerZeroCross = mng.create("Series", "SerZeroCross");
	MarSystem* SerRms = mng.create("Series", "SerRms");
	MarSystem* SerAmdf = mng.create("Series", "SerAmdf");
	MarSystem* SerMFCC = mng.create("Series", "SerMFCC");
	MarSystem* SerLPC = mng.create("Series", "SerLPC");
	MarSystem* SerMaxMin = mng.create("Series", "SerMaxMin"); //Distorting sound
	MarSystem* SerPeaker = mng.create("Series", "SerPeaker");
	MarSystem* SerChroma = mng.create("Series", "SerChroma");
	MarSystem* SerEnergy = mng.create("Series", "SerEnergy");
	//MarSystem* SerSCF = mng.create("Series", "SerSCF"); //Enough feature are up there no space for more.
														  //You can replace above ones by below ones to make them work.
	//MarSystem* SerSFM = mng.create("Series", "SerSFM"); //many values coming out as 'nan'
	//MarSystem* SerSnr = mng.create("Series", "SerSnr");
	//MarSystem* SerSpecSnr = mng.create("Series", "SerSepecSnr"); //printing extra stuff!!
	//MarSystem* SerF0analysis = mng.create("Series", "F0analysis");
	
	// standard network
	pnet->addMarSystem(mng.create("SoundFileSource", "src"));
	pnet->updctrl("SoundFileSource/src/mrs_string/filename", sfName);
	
	Fanout1->addMarSystem(mng.create("AudioSink", "dest"));
	Fanout1->updctrl("AudioSink/dest/mrs_bool/initAudio", true);
	
	Spec->addMarSystem(mng.create("Spectrum","spk"));
	
	SerCentroid->addMarSystem(mng.create("Centroid", "centeroid"));
	SerCentroid->addMarSystem(mng.create("Gain", "g2"));
	
	SerRolloff->addMarSystem(mng.create("Rolloff", "rolloff"));
	SerRolloff->addMarSystem(mng.create("Gain", "g3"));
	
	SerFlux->addMarSystem(mng.create("Flux", "flux"));
	//SerFlux->updctrl("Flux/flux/mrs_bool/reset",true);
	SerFlux->addMarSystem(mng.create("Gain", "g4"));
	
	SerSpecMean->addMarSystem(mng.create("Mean", "Specmean"));
	SerSpecMean->addMarSystem(mng.create("Gain", "g5"));
	
	SerSpecMed->addMarSystem(mng.create("Median", "Specmed"));
	SerSpecMed->addMarSystem(mng.create("Gain", "g15"));
	
	SerSkew->addMarSystem(mng.create("Skewness", "skewness"));
	SerSkew->addMarSystem(mng.create("Gain", "g7"));
	
	SerKurtosis->addMarSystem(mng.create("Kurtosis", "kurtosis"));
	SerKurtosis->addMarSystem(mng.create("Gain", "g8"));
	
	SerPower->addMarSystem(mng.create("Power", "power"));
	SerPower->addMarSystem(mng.create("Gain", "g8"));
	
	SerAutoCor->addMarSystem(mng.create("AutoCorrelation", "autocor"));
	SerAutoCor->addMarSystem(mng.create("Gain", "g9"));
	
	SerRms->addMarSystem(mng.create("Rms", "rms"));
	SerRms->addMarSystem(mng.create("Gain", "g11"));
	
	SerMFCC->addMarSystem(mng.create("PowerSpectrum", "powspec"));
	SerMFCC->addMarSystem(mng.create("MFCC", "mfcc"));
	SerMFCC->addMarSystem(mng.create("Gain", "g13"));
	
	SerLPC->addMarSystem(mng.create("LPC", "lpc"));
	//SerLPC->updctrl("LPC/lpc/mrs_natural/order",5);
	SerLPC->addMarSystem(mng.create("LPCC", "lpcc"));
	//SerLPC->addMarSystem(mng.create("LSP", "lsp"));
	SerLPC->addMarSystem(mng.create("Gain", "g14"));
	
	SerMaxMin->addMarSystem(mng.create("MaxMin", "maxmin"));
	SerMaxMin->addMarSystem(mng.create("Gain", "g16"));
	
	SerChroma->addMarSystem(mng.create("Chroma", "chroma"));
	SerChroma->addMarSystem(mng.create("Gain", "g18"));
	
	////SerSCF->addMarSystem(mng.create("SCF", "scf"));
	////SerSCF->addMarSystem(mng.create("Gain", "g20"));
	
	////SerSFM->addMarSystem(mng.create("SFM", "sfm"));
	////SerSFM->addMarSystem(mng.create("Gain", "g21"));
	
	////SerSpecSnr->addMarSystem(mng.create("SpectralSNR", "specsnr"));
	////SerSpecSnr->addMarSystem(mng.create("Gain", "g23"));
	
	Fanout2->addMarSystem(SerCentroid);
//.........这里部分代码省略.........
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:101,代码来源:helloWorld.cpp

示例15: recognize

double* recognize(string sfName)
{
	MarSystemManager mng;
	MarSystem* pnet = mng.create("Series", "pnet");
	MarSystem* Fanout1 = mng.create("Fanout","Fanout1");
	MarSystem* Fanout2 = mng.create("Fanout","Fanout2");
	MarSystem* Spec = mng.create("Series", "Spec");
	MarSystem* SerCentroid = mng.create("Series", "SerCentroid");
	MarSystem* SerRolloff = mng.create("Series", "SerRolloff");
	MarSystem* SerFlux = mng.create("Series", "SerFlux");
	MarSystem* SerSpecMean = mng.create("Series", "SerSpecMean");
	MarSystem* SerSpecMed = mng.create("Series", "SerSpecMed");
	//MarSystem* SerMean = mng.create("Series", "SerMean");		//comming same as spectral Mean
	MarSystem* SerStdDev = mng.create("Series", "SerStdDev");
	MarSystem* SerSkew = mng.create("Series", "SerSkew");
	MarSystem* SerKurtosis = mng.create("Series", "SerKurtosis");
	MarSystem* SerPower = mng.create("Series", "SerPower");
	MarSystem* SerAutoCor = mng.create("Series", "SerAutoCor");
	MarSystem* SerZeroCross = mng.create("Series", "SerZeroCross");
	MarSystem* SerRms = mng.create("Series", "SerRms");
	MarSystem* SerAmdf = mng.create("Series", "SerAmdf");
	MarSystem* SerMFCC = mng.create("Series", "SerMFCC");
	MarSystem* SerLPC = mng.create("Series", "SerLPC");
	MarSystem* SerMaxMin = mng.create("Series", "SerMaxMin"); //Distorting sound
	MarSystem* SerPeaker = mng.create("Series", "SerPeaker");
	MarSystem* SerChroma = mng.create("Series", "SerChroma");
	MarSystem* SerEnergy = mng.create("Series", "SerEnergy");
	//MarSystem* SerSCF = mng.create("Series", "SerSCF"); //Enough feature are up there no space for more.
														  //You can replace above ones by below ones to make them work.
	//MarSystem* SerSFM = mng.create("Series", "SerSFM"); //many values coming out as 'nan'
	//MarSystem* SerSnr = mng.create("Series", "SerSnr");
	//MarSystem* SerSpecSnr = mng.create("Series", "SerSepecSnr"); //printing extra stuff!!
	//MarSystem* SerF0analysis = mng.create("Series", "F0analysis");
	
	// standard network
	pnet->addMarSystem(mng.create("SoundFileSource", "src"));
	pnet->updctrl("SoundFileSource/src/mrs_string/filename", sfName);
	
	Fanout1->addMarSystem(mng.create("AudioSink", "dest"));
	Fanout1->updctrl("AudioSink/dest/mrs_bool/initAudio", true);
	
	Spec->addMarSystem(mng.create("Spectrum","spk"));
	
	SerCentroid->addMarSystem(mng.create("Centroid", "centeroid"));
	SerCentroid->addMarSystem(mng.create("Gain", "g2"));
	
	SerRolloff->addMarSystem(mng.create("Rolloff", "rolloff"));
	SerRolloff->addMarSystem(mng.create("Gain", "g3"));
	
	SerFlux->addMarSystem(mng.create("Flux", "flux"));
	//SerFlux->updctrl("Flux/flux/mrs_bool/reset",true);
	SerFlux->addMarSystem(mng.create("Gain", "g4"));
	
	SerSpecMean->addMarSystem(mng.create("Mean", "Specmean"));
	SerSpecMean->addMarSystem(mng.create("Gain", "g5"));
	
	SerSpecMed->addMarSystem(mng.create("Median", "Specmed"));
	SerSpecMed->addMarSystem(mng.create("Gain", "g15"));
	
	SerSkew->addMarSystem(mng.create("Skewness", "skewness"));
	SerSkew->addMarSystem(mng.create("Gain", "g7"));
	
	SerKurtosis->addMarSystem(mng.create("Kurtosis", "kurtosis"));
	SerKurtosis->addMarSystem(mng.create("Gain", "g8"));
	
	SerPower->addMarSystem(mng.create("Power", "power"));
	SerPower->addMarSystem(mng.create("Gain", "g8"));
	
	SerAutoCor->addMarSystem(mng.create("AutoCorrelation", "autocor"));
	SerAutoCor->addMarSystem(mng.create("Gain", "g9"));
	
	SerRms->addMarSystem(mng.create("Rms", "rms"));
	SerRms->addMarSystem(mng.create("Gain", "g11"));
	
	SerMFCC->addMarSystem(mng.create("PowerSpectrum", "powspec"));
	SerMFCC->addMarSystem(mng.create("MFCC", "mfcc"));
	SerMFCC->addMarSystem(mng.create("Gain", "g13"));
	
	SerLPC->addMarSystem(mng.create("LPC", "lpc"));
	//SerLPC->updctrl("LPC/lpc/mrs_natural/order",5);
	SerLPC->addMarSystem(mng.create("LPCC", "lpcc"));
	//SerLPC->addMarSystem(mng.create("LSP", "lsp"));
	SerLPC->addMarSystem(mng.create("Gain", "g14"));
	
	SerMaxMin->addMarSystem(mng.create("MaxMin", "maxmin"));
	SerMaxMin->addMarSystem(mng.create("Gain", "g16"));
	
	SerChroma->addMarSystem(mng.create("Chroma", "chroma"));
	SerChroma->addMarSystem(mng.create("Gain", "g18"));
	
	////SerSCF->addMarSystem(mng.create("SCF", "scf"));
	////SerSCF->addMarSystem(mng.create("Gain", "g20"));
	
	////SerSFM->addMarSystem(mng.create("SFM", "sfm"));
	////SerSFM->addMarSystem(mng.create("Gain", "g21"));
	
	////SerSpecSnr->addMarSystem(mng.create("SpectralSNR", "specsnr"));
	////SerSpecSnr->addMarSystem(mng.create("Gain", "g23"));
	
	Fanout2->addMarSystem(SerCentroid);
//.........这里部分代码省略.........
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:101,代码来源:helloWorld.cpp


注:本文中的MarSystem::updctrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。