/** * @short Gets the audio signals for both channels (actually a copy) */ void Polybase::getAudio(float *audio[2], unsigned int nsamples, const MidiEventList &list){ if (nsamples>chunksize){ if (chunk){ delete chunk; } chunk=new float[nsamples]; } unsigned int uptoSample=0; unsigned int i; foreach(MidiEvent ev, list){ if (ev.sampleOffset>uptoSample){ calculateChunk(&audio[0][uptoSample], ev.sampleOffset-uptoSample); uptoSample=ev.sampleOffset; } switch (ev.type){ case MidiEvent::noteOn: noteOn(ev.data[0], ev.data[1]); break; case MidiEvent::noteOff: noteOff(ev.data[0], ev.data[1]); break; case MidiEvent::controller: controller(ev.data[0], ev.data[1]); break; default: break; } } calculateChunk(&audio[0][uptoSample], nsamples-uptoSample); for (i=0;i<nsamples;i++){ float s=audio[0][i]*volume; if (s>1.0 || s<-1.0){ volume*=0.9; if (s<0.0) s=-1.0; else s=1.0; WARNING("Clip %f! lowering volume to %f", s, volume); emit sendController(0, volume*127); } audio[0][i]=s; } // no stereo by the moment memcpy(audio[1],audio[0],sizeof(float)*nsamples); }
void DLargestCommonSubSequence::process() { printString("A", a_); printString("B", b_); for(int i = 0; i < n_; ++i) { if(id_ == i) { std::cout << "Proc {" << i << "}\n" << std::flush; distributedInit(); } bsp_sync(); } double tStart = bsp_time(); { for(int a = 0; a < 2*chunkStride_-1; ++a) { //if(0 == id_) // std::cout << "Wavefront " << a << std::endl << std::flush; // copy required elements from over_ buffer to L int indexInOver = 0; for(int i = 1; i < chunkStride_; ++i) { for(int j = 0; j < chunkStride_; ++j) { if( a == i + j && id_ == i % n_) { memcpy(L_[getCPair(i-1, j)][chunkLength_-1], over_[indexInOver].data(), sizeof(int)*chunkLength_); ++indexInOver; } } } // calculate for(int i = 0; i < chunkStride_; ++i) { for(int j = 0; j < chunkStride_; ++j) { if( a == i + j && id_ == i % n_) { //std::cout << "calculateChunk[" << i << ", " // << j << "] held by proc " << id_ // << std::endl << std::flush; calculateChunk(i, j); } } } // communicate rows indexInOver = 0; for(int i = 0; i < chunkStride_; ++i) { for(int j = 0; j < chunkStride_; ++j) { if( a == i + j && id_ == i % n_ && chunkStride_-1 != i ) { //std::cout << "dstPROC {" << (i+1)%n_ << "} with index [" // << indexInOver << "], source - from PROC {" // << id_ << "} with cell [" // << i <<","<< j // << "]" << std::endl << std::flush; //std::cout << "src ptr " << L_[getCPair(i, j)][G-1] // << std::endl << std::flush; //std::cout << "dst ptr " << over_[indexInOver].data() // << std::endl << std::flush; bsp_put((i+1)%n_, L_[getCPair(i, j)][chunkLength_-1], over_[indexInOver].data(), 0, chunkLength_*sizeof(int)); ++indexInOver; } } } bsp_sync(); } } double tEnd = bsp_time(); if(0 == id_) std::cout << "Problem size [" << length_ << "]" << std::endl << "Time = " << tEnd - tStart << std::endl; bsp_sync(); if(n_-1 == id_) { std::cout << "No way we got a result " << getLElem(length_-1, length_-1) << std::endl; } }