void tdc::setWindowOffset(int OffsetSetting) { if (OffsetSetting > 40 || OffsetSetting < -2048){if(vLevel(WARNING))cout << "Offset Setting must be a integer in the range from -2048 to +40" << endl;} else {unsigned int DATA = 0x1100; writeOpcode(DATA); DATA = OffsetSetting; writeOpcode(DATA); cout << "Window Width set to"<< OffsetSetting<< endl; } }
void tdc::setWindowWidth(unsigned int WidthSetting) { if (WidthSetting > 4095 ){if(vLevel(WARNING))cout << "Width Setting must be a integer in the range from 1 to 4095" << endl;} else {unsigned int DATA=0x1000; writeOpcode(DATA); DATA = WidthSetting; writeOpcode(DATA); cout << "Window Width set to"<< WidthSetting<< endl; } }
void tdc::disableTDCHeaderAndTrailer() { unsigned int DATA = 0x3100; writeOpcode(DATA); DATA = 0x3200; writeOpcode(DATA); readOpcode(DATA); if (DATA%2==0) if(vLevel(NORMAL))cout << "TDC Header and Trailer disabled"<< endl; }
void tdc::setRejectMargin(int RejectMrgnSetting) { if (RejectMrgnSetting > 4095) {if(vLevel(WARNING))cout << "Offset Setting must be a integer in the range from -2048 to +40" << endl;} else {unsigned int DATA = 0x1300; writeOpcode(DATA); DATA = RejectMrgnSetting; writeOpcode(DATA); if(vLevel(NORMAL))cout << "Reject Margin set to"<< RejectMrgnSetting<< endl; } }
void tdc::setExSearchMargin(int ExSearchMrgnSetting ) { if (ExSearchMrgnSetting > 50){if(vLevel(WARNING)) cout << " 50*25ns is the maximal value. Extra Search Margin Setting must be a integer in the range from 0 to 50" << endl;} else {unsigned int DATA = 0x1200; writeOpcode(DATA); DATA = ExSearchMrgnSetting; writeOpcode(DATA); if(vLevel(NORMAL))cout << "Extra Search Margin Width set to"<< ExSearchMrgnSetting<< endl; } }
void RemotePluginClient::setVSTChunk(std::vector<char> chunk) { std::cerr << "RemotePluginClient::setChunk: writing vst chunk.." << std::endl; std::cerr << "RemotePluginClient::setChunk: read vst chunk, size=" << chunk.size() << std::endl; writeOpcode(m_controlRequestFd, RemotePluginSetVSTChunk); writeRaw(m_controlRequestFd, chunk); }
void tdc::setMode(bool Trig){ unsigned int DATA=0; if(Trig) DATA = 0x0000; else DATA =0x0100; writeOpcode(DATA); if(vLevel(DEBUG))cout << "Trigger Mode : " << Trig<< endl; }
std::string RemotePluginClient::getProgramName(int n) { writeOpcode(m_controlRequestFd, RemotePluginGetProgramName); writeInt(m_controlRequestFd, n); return readString(m_controlResponseFd); }
void tdc::readResolution() { unsigned int DATA=0x2600; writeOpcode(DATA); readOpcode(DATA); if(vLevel(NORMAL))cout<<" resolution : "<<digit(DATA,1,0)<<endl;; }
float RemotePluginClient::getVersion() { //!!! client code needs to be testing this writeOpcode(m_controlRequestFd, RemotePluginGetVersion); return readFloat(m_controlResponseFd); }
float RemotePluginClient::getParameterDefault(int p) { writeOpcode(m_controlRequestFd, RemotePluginGetParameterDefault); writeInt(m_controlRequestFd, p); return readFloat(m_controlResponseFd); }
int RemotePluginClient::getOutputCount() { writeOpcode(m_controlRequestFd, RemotePluginGetOutputCount); m_numOutputs = readInt(m_controlResponseFd); sizeShm(); return m_numOutputs; }
void RemotePluginClient::reset() { writeOpcode(m_controlRequestFd, RemotePluginReset); if (m_shmSize > 0) { memset(m_shm, 0, m_shmSize); } }
void RemotePluginClient::setSampleRate(int s) { writeOpcode(&m_shmControl->ringBuffer, RemotePluginSetSampleRate); writeInt(&m_shmControl->ringBuffer, s); commitWrite(&m_shmControl->ringBuffer); waitForServer(); }
bool RemotePluginClient::hasMIDIInput() { writeOpcode(m_controlRequestFd, RemotePluginHasMIDIInput); bool b; tryRead(m_controlResponseFd, &b, sizeof(bool)); return b; }
void RemotePluginClient::setParameter(int p, float v) { writeOpcode(&m_shmControl->ringBuffer, RemotePluginSetParameter); writeInt(&m_shmControl->ringBuffer, p); writeFloat(&m_shmControl->ringBuffer, v); commitWrite(&m_shmControl->ringBuffer); }
void RemotePluginClient::setCurrentProgram(int n) { writeOpcode(&m_shmControl->ringBuffer, RemotePluginSetCurrentProgram); writeInt(&m_shmControl->ringBuffer, n); commitWrite(&m_shmControl->ringBuffer); waitForServer(); }
//Deryabin Andrew: vst chunks support std::vector<char> RemotePluginClient::getVSTChunk() { std::cerr << "RemotePluginClient::getChunk: getting vst chunk.." << std::endl; writeOpcode(m_controlRequestFd, RemotePluginGetVSTChunk); std::vector<char> chunk = readRaw(m_controlResponseFd); std::cerr << "RemotePluginClient::getChunk: got vst chunk, size=" << chunk.size() << std::endl; return chunk; }
void RemotePluginClient::getParameters(int p0, int pn, float *v) { writeOpcode(m_controlRequestFd, RemotePluginGetParameters); writeInt(m_controlRequestFd, p0); writeInt(m_controlRequestFd, pn); tryRead(m_controlResponseFd, v, (pn - p0 + 1) * sizeof(float)); }
bool RemotePluginClient::warn(std::string str) { writeOpcode(m_controlRequestFd, RemotePluginWarn); writeString(m_controlRequestFd, str); bool b; tryRead(m_controlResponseFd, &b, sizeof(bool)); return b; }
void tdc::setMaxEvPerHit(int Max_ev_per_hit){ for(int k=0; k<8;k++) if (Max_ev_per_hit== (2^(k))) { if(vLevel(NORMAL))if (k == 8) cout << "No limit on Maximum number of hits per event"; unsigned int DATA=0x3300; // MEPH = maximum events per hits writeOpcode(DATA); DATA = k+1; writeOpcode(DATA); } else if (Max_ev_per_hit==0) { unsigned int DATA=0x3300; writeOpcode(DATA); DATA=0; writeOpcode(DATA); } else if(vLevel(WARNING))cout<< "Not a valid set ! value of Max number of hits per event must be 0 or a power of 2 (1 2 4 .. 128) or 256 for NO LIMIT"; }
void RemotePluginClient::setBufferSize(int s) { if (s == m_bufferSize) return; m_bufferSize = s; sizeShm(); writeOpcode(&m_shmControl->ringBuffer, RemotePluginSetBufferSize); writeInt(&m_shmControl->ringBuffer, s); commitWrite(&m_shmControl->ringBuffer); waitForServer(); }
void RemotePluginClient::process(float **inputs, float **outputs) { //struct timeval start, finish; //gettimeofday(&start, 0); if (m_bufferSize < 0) { std::cerr << "ERROR: RemotePluginClient::setBufferSize must be called before RemotePluginClient::process" << std::endl; return; } if (m_numInputs < 0) { std::cerr << "ERROR: RemotePluginClient::getInputCount must be called before RemotePluginClient::process" << std::endl; return; } if (m_numOutputs < 0) { std::cerr << "ERROR: RemotePluginClient::getOutputCount must be called before RemotePluginClient::process" << std::endl; return; } if (!m_shm) { std::cerr << "ERROR: RemotePluginClient::process: no shared memory region available" << std::endl; return; } size_t blocksz = m_bufferSize * sizeof(float); //!!! put counter in shm to indicate number of blocks processed? // (so we know if we've screwed up) for (int i = 0; i < m_numInputs; ++i) { memcpy(m_shm + i * blocksz, inputs[i], blocksz); } writeOpcode(&m_shmControl->ringBuffer, RemotePluginProcess); commitWrite(&m_shmControl->ringBuffer); waitForServer(); for (int i = 0; i < m_numOutputs; ++i) { memcpy(outputs[i], m_shm + (i + m_numInputs) * blocksz, blocksz); } // std::cout << "process: wrote opcode " << RemotePluginProcess << std::endl; //gettimeofday(&finish, 0); // std::cout << "process: time " << finish.tv_sec - start.tv_sec // << " sec, " << finish.tv_usec - start.tv_usec << " usec" // << std::endl; return; }
void tdc::readWindowConfiguration() { unsigned int DATA=0x1600; writeOpcode(DATA); readOpcode(DATA); if(vLevel(NORMAL))cout<<" Match window width : "<<digit(DATA,11,0); readOpcode(DATA); if(vLevel(NORMAL))cout<<" Window ofset : "<<digit(DATA,11,0)-4096; readOpcode(DATA); if(vLevel(NORMAL))cout<<" Extra search window width: "<<digit(DATA,11,0); readOpcode(DATA); if(vLevel(NORMAL))cout<<" Reject margin width: "<<digit(DATA,11,0); readOpcode(DATA); if(vLevel(NORMAL))cout<<" Trigger time substraction : "<<digit(DATA,0); }
void RemotePluginClient::sendMIDIData(unsigned char *data, int *frameoffsets, int events) { writeOpcode(&m_shmControl->ringBuffer, RemotePluginSendMIDIData); writeInt(&m_shmControl->ringBuffer, events); tryWrite(&m_shmControl->ringBuffer, data, events * 3); if (!frameoffsets) { // This should not happen with a good client, but we'd better // cope as well as possible with the lazy ol' degenerates frameoffsets = (int *)alloca(events * sizeof(int)); memset(frameoffsets, 0, events * sizeof(int)); } // std::cerr << "RemotePluginClient::sendMIDIData(" << events << ")" << std::endl; tryWrite(&m_shmControl->ringBuffer, frameoffsets, events * sizeof(int)); commitWrite(&m_shmControl->ringBuffer); }
void RemotePluginClient::hideGUI() { writeOpcode(m_controlRequestFd, RemotePluginHideGUI); }
void RemotePluginClient::showGUI(std::string guiData) { writeOpcode(m_controlRequestFd, RemotePluginShowGUI); writeString(m_controlRequestFd, guiData); }
void RemotePluginClient::setDebugLevel(RemotePluginDebugLevel level) { writeOpcode(m_controlRequestFd, RemotePluginSetDebugLevel); tryWrite(m_controlRequestFd, &level, sizeof(RemotePluginDebugLevel)); }
int RemotePluginClient::getProgramCount() { writeOpcode(m_controlRequestFd, RemotePluginGetProgramCount); return readInt(m_controlResponseFd); }
void RemotePluginClient::terminate() { writeOpcode(m_controlRequestFd, RemotePluginTerminate); }