src/JackHandler.h
branchv_0
changeset 12 f56620b95180
parent 11 1c0b9981eb6d
child 13 a85c191709e6
equal deleted inserted replaced
11:1c0b9981eb6d 12:f56620b95180
   192 		// TODO: configurable relation name
   192 		// TODO: configurable relation name
   193 	}
   193 	}
   194 
   194 
   195 	void attribute(const relpipe::common::type::StringX& value) override {
   195 	void attribute(const relpipe::common::type::StringX& value) override {
   196 		// TODO: switch to RelationalReaderStringHandler
   196 		// TODO: switch to RelationalReaderStringHandler
   197 		// TODO: append to current message + if this is last attribute, put whole message to the ring buffer
       
   198 		// TODO: if (continueProcessing) {} ?
   197 		// TODO: if (continueProcessing) {} ?
   199 
   198 
   200 		// memcpy(currentMidiMessage.buffer, ….buffer, ….size);
   199 		// memcpy(currentMidiMessage.buffer, ….buffer, ….size);
   201 		// currentMidiMessage.size = …;
   200 		// currentMidiMessage.size = …;
   202 		// currentMidiMessage.time = …;
   201 		// currentMidiMessage.time = …;
   203 
       
   204 		// TODO: correct timing?
       
   205 		// TODO: real data
       
   206 
   202 
   207 		{
   203 		{
   208 			RelationContext& rel = relationContext;
   204 			RelationContext& rel = relationContext;
   209 			RelationContext::RecordContext& rec = rel.recordContext;
   205 			RelationContext::RecordContext& rec = rel.recordContext;
   210 
   206 
   219 		}
   215 		}
   220 
   216 
   221 		relationContext.recordContext.attributeIndex++;
   217 		relationContext.recordContext.attributeIndex++;
   222 
   218 
   223 		if (relationContext.recordContext.attributeIndex == relationContext.attributeCount) {
   219 		if (relationContext.recordContext.attributeIndex == relationContext.attributeCount) {
   224 			if (jack_ringbuffer_write_space(realTimeContext.ringBuffer) >= sizeof (MidiMessage)) {
   220 
   225 				MidiMessage m;
   221 			while (jack_ringbuffer_write_space(realTimeContext.ringBuffer) < sizeof (MidiMessage)) usleep(1000); // should not happen, the real-time thread should be faster
   226 
   222 
   227 				// TODO: convert relationContext.recordContext to m
   223 			MidiMessage m;
   228 				m.time = 0;
   224 
   229 				m.size = 3;
   225 			// TODO: convert relationContext.recordContext to m
   230 				m.buffer[0] = 0x90;
   226 			// TODO: correct timing?
   231 				m.buffer[1] = 0x24;
   227 			m.time = 0;
   232 				m.buffer[2] = 0x40;
   228 			m.size = 3;
   233 
   229 			m.buffer[0] = 0x90;
   234 				jack_ringbuffer_write(realTimeContext.ringBuffer, (const char *) &m, sizeof (m));
   230 			m.buffer[1] = 0x24;
   235 			} else {
   231 			m.buffer[2] = 0x40;
   236 				fwprintf(stderr, L"Error: ring buffer is full → skipping event.\n");
   232 
   237 			}
   233 			jack_ringbuffer_write(realTimeContext.ringBuffer, (const char *) &m, sizeof (m));
   238 
   234 
   239 			relationContext.recordContext = RelationContext::RecordContext();
   235 			relationContext.recordContext = RelationContext::RecordContext();
   240 		}
   236 		}
   241 
   237 
   242 	}
   238 	}