void ZMQAcceptor::sendReply( const std::string& msg ) { _socket.send( _lastSender, ZMQ_SNDMORE ); zmq::message_t zmsg( msg.size() ); memcpy( zmsg.data(), msg.data(), msg.size() ); _socket.send( zmsg ); }
int main(int argc, char **argv){ int i; int j; printf("tst_trace server you...\n"); ztrace_reg(tst_trace, (void*)0); zdbg("zdbg(int<%d>)", 11111); zmsg("zmdg(double<%f>)", 3.1415926); zwar("zwar(string<%s>)", "string test"); zerr("zerr(<int:%d, dobule:%f, string:%s)",222,3.1415,"string test"); ZDBG("ZDBG(int<%04d>)",333); ZMSG("ZMSG(float<%.2f>", 2.1415); ZWAR("ZWAR(int:%d .2f:%.2f, string:%s", 444, 3.156, "test string"); ZERR("ZERR"); ZERRCX(ZOK); ZERRC(ZOK); for(i=1; i<=ZE_END; i++){ j = i | ZEMASK; ZERRCX(j); } return(0); }
int zact_intque(zvalue_t user, zvalue_t hint){ int* index = (int*)hint; zmsg("queue[%03d] = %d", *index, user); ++(*index); return ZEOK; }
void ZMQConnector::send( const std::string& msg ) { zmq::message_t zmsg( msg.size() ); memcpy( zmsg.data(), msg.data(), msg.size() ); _socket.send( zmsg ); }
void VSTInstrument::processReplacing(float** inputs, float** outputs, VstInt32 sampleFrames) { renderMutex.Lock(); // Before rendering, set rounding flags, and denormal flags ZFPUState fpuState(ZFPUState::kRoundToZero); // If neccesary, create or reload synth if (programFile.DidUpdate()) { if (synth) { delete synth; synth = nullptr; } auto prog = invader::ZVMProgram::FromBlob(programFile.data); prog->Unpack(); synth = new invader::ZSynth(prog); } eventQueueMutex.Lock(); int32_t numSamplesToRender = ((int32_t)sampleFrames)-((int32_t)sampleBuffer.SamplesAvailable()); // Get time info VstTimeInfo *timeInfo = getTimeInfo(kVstPpqPosValid | kVstTempoValid | kVstBarsValid | kVstCyclePosValid | kVstTimeSigValid | kVstTransportPlaying); synth->sync.bpm = (timeInfo && (timeInfo->flags & kVstTempoValid)) ? timeInfo->tempo : 120.0f; synth->sync.bps = synth->sync.bpm / 60.0f; bool shouldSync = timeInfo && (timeInfo->flags & kVstPpqPosValid) && (timeInfo->flags & kVstTransportPlaying); if (shouldSync) { synth->sync.pos = timeInfo->ppqPos; // Compensate for samples already generated synth->sync.pos += (double)sampleBuffer.SamplesAvailable() / kSampleRate * synth->sync.bps; } synth->sync.time = synth->sync.pos / synth->sync.bps; // Loop over blocks while (numSamplesToRender > 0) { // Handle relevant events while (!eventQueue.empty() && eventQueue.front().deltaFrames < kBlockSize) { VstMidiEvent event = eventQueue.front(); char* midiData = event.midiData; zmsg("Midi Event: %02X %02X %02X\n", (unsigned char)midiData[0], (unsigned char)midiData[1], (unsigned char)midiData[2]); uint32_t channel = uint32_t(midiData[0]) & 0x0f; uint32_t status = uint32_t(midiData[0]) & 0xf0; if (status == 0x90 || status == 0x80) // Note on or note off { uint32_t note = uint32_t(midiData[1]) & 0x7f; uint32_t velocity = uint32_t(midiData[2]) & 0x7f; if (status == 0x80) velocity = 0; // note off by velocity 0 if (velocity==0) { synth->NoteOff((uint32_t)channel, (uint32_t)note, (uint32_t)event.deltaFrames); } else { synth->NoteOn((uint32_t)channel, (uint32_t)note, (uint32_t)velocity, (uint32_t)event.deltaFrames); } } else if (status == 0xB0) // MIDI control change { uint32_t number = uint32_t(midiData[1]) & 0x7f; uint32_t value = uint32_t(midiData[2]) & 0x7f; synth->ControlChange(channel, number, value, (uint32_t)event.deltaFrames); } eventQueue.pop_front(); } // Render blocks synth->ProcessBlock(); // Resample // Access here is a little hackish, we're relying on storage of sample block outputs to be stored continually in global storage, starting at zero //ZResampler2xDownsample(*downsampler, downsampleBuffer, synth->vm.globalStorage->Load<ZBlockBufferInternal>((invader::opcode_index_t)(synth->section*sizeof(ZBlockBufferInternal)))); ZResampler2xDownsample(*downsampler, downsampleBuffer, synth->vm.stack->Pop<ZBlockBufferInternal>()); sampleBuffer.PutBlock(downsampleBuffer); numSamplesToRender -= kBlockSize; // Decrement deltaSamples in events in queue for (event_queue_t::iterator it = eventQueue.begin(); it != eventQueue.end(); ++it) it->deltaFrames -= kBlockSize; } eventQueueMutex.Unlock(); renderMutex.Unlock(); // Deinterleave output into buffers for (int32_t i=0; i<sampleFrames; i++) { sample_t sample = sampleBuffer.GetSample(); outputs[0][i] = (float)sample.d[0]; outputs[1][i] = (float)sample.d[1]; } /*// We must always clear the buffer, to ensure non-garbage output Buffer dest; dest.channels[0]=outputs[0]; dest.channels[1]=outputs[1]; dest.numChannels=2; dest.numSamples=sampleFrames; dest.Reset(); // Only do this if replacing buffer // Note: This is mostly useful if some operation (e.g. synth realod) takes a while // We are not guarenteed that synth has not been reloaded when we get to the lock if (synth->shouldRender==false) { return; } synth->renderMutex.Lock(); // Recheck if (synth->shouldRender==false) { synth->renderMutex.Unlock(); return; } // Get time info VstTimeInfo *timeInfo = getTimeInfo(kVstPpqPosValid | kVstTempoValid | kVstBarsValid | kVstCyclePosValid | kVstTimeSigValid | kVstTransportPlaying); synth->timeInfo.bpm = (timeInfo && (timeInfo->flags & kVstTempoValid)) ? timeInfo->tempo : 120.0f; synth->timeInfo.bps = synth->timeInfo.bpm / 60.0f; bool shouldSync = timeInfo && (timeInfo->flags & kVstPpqPosValid) && (timeInfo->flags & kVstTransportPlaying); if (shouldSync) synth->timeInfo.pos = timeInfo->ppqPos; // Process, but support samplesFrames other than 256 synth->ProcessNon256(&dest); synth->renderMutex.Unlock(); */ return; }
bool IEvent::Service::Publisher::publish(std::string message) { zmq::message_t zmsg(message.length()); memcpy(zmsg.data(), message.c_str(), message.length()); return _publisher.send(zmsg); }