Any chance of a quick hex & midi data lesson!

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

&= havn't tried that!

Post

Still sending program change messages?

Post

Then take a closer look here.

Code: Select all

	char x = 144;
	unsigned char y = 144;
What do you think, will be in x and y after that?
What is the valid range of a char?
What the valid range of an unsigned char?

Lies 144 inside that range in both cases?

Maybe the &0x7F stuff (AND assignment) has any sense ... :)

(I cannot very good explain that, because the language barriere...)
But if you assign a value of 144 to a char you actually get -112 as a value, because you exceeded the valid range of that data type by doing so.

That meight be the reason for your wrong assignment and not working of your code.

Post

Tried unsigned char but the vst definitions are:

Code: Select all

//---Defined Events--------------------------------
struct VstMidiEvent		// to be casted from a VstEvent
{
	long type;			// kVstMidiType
	long byteSize;		// 24
	long deltaFrames;	// sample frames related to the current block start sample position
	long flags;			// none defined yet

	long noteLength;	// (in sample frames) of entire note, if available, else 0
	long noteOffset;	// offset into note from note start if available, else 0

	char midiData[4];	// 1 thru 3 midi bytes; midiData[3] is reserved (zero)
	char detune;		// -64 to +63 cents; for scales other than 'well-tempered' ('microtuning')
	char noteOffVelocity;
	char reserved1;		// zero
	char reserved2;		// zero
};
So why does it let me do:

Code: Select all

SendableMidiEventList[i].midiData[0] = 144; 
?

Post

So why does my code work and your's not ? :wink:
ps: I know the VST spec. Very well.

Post

Code: Select all

eventMidiData0[i] = 144;
Joe,

I neither know what eventMidiData0 is nor what that index i describes. So it could also be, that the problem anywhere there is.

Post

The original code from jtrig was:

Code: Select all

SendableMidiEventList[i].type = kVstMidiType;
				SendableMidiEventList[i].byteSize = 24L;
				SendableMidiEventList[i].deltaFrames = currentframe;
				SendableMidiEventList[i].flags = 0L;
				SendableMidiEventList[i].noteLength = 0L;
				SendableMidiEventList[i].noteOffset = 0L;
				SendableMidiEventList[i].midiData[0] = 0x90 | (iChan - 1);
				SendableMidiEventList[i].midiData[1] = iNote;
				SendableMidiEventList[i].midiData[2] = 64;
				SendableMidiEventList[i].midiData[3] = 0;
				SendableMidiEventList[i].detune = 0;
				SendableMidiEventList[i].noteOffVelocity = 0;
				SendableMidiEventList[i].reserved1 = 0;
				SendableMidiEventList[i].reserved2 = 0;
				SendableVstEvents->numEvents++;
				SendableVstEvents->events[i++] = 
						(VstEvent*) &SendableMidiEventList[i];
where iChan=1 this still returns 144 but signed char = 144 returns -112???

Post

Have to go for a bit, I'll be thinking about it!

Post

It's sorted?

dumb programming error!

It will let me use decimals so I can do the way I know, but I think I will try and use the hex and MIDI.h file from Midi_Gain!

Thanks for your help again and sorry to wast e your time.

Joe

Post

I've had so many problems with midi out lists called from process causing damaged block errors when closing the plug that I had to try the old "atari" method of one at a time inside the loop. It seems to work perfectly now, so I'd thought I'd show you to see if you'd say "no no no no no no not all that inside the sample loop!!!" or if you think it could be simplified even further and how often you think this could be called? It doesn't need to be that often for my purposes.

Anyway:

Code: Select all

while(--sampleFrames >= 0)
{
if(sendMidi)
{
SendableVstEvents->numEvents = 1;
			SendableMidiEventList[0].type = kVstMidiType;
			SendableMidiEventList[0].deltaFrames = sampleFrames;
			SendableMidiEventList[0].midiData[0] = status;
			SendableMidiEventList[0].midiData[1] = data1;
			SendableMidiEventList[0].midiData[2] = data2;
						SendableVstEvents->events[0] = (VstEvent*) &SendableMidiEventList[0];
			sendVstEventsToHost(SendableVstEvents);
}
)			
I think I have to go this way to get a working prototype and then maybe get some help to re-code later.
Or maybe this will be fine?

Joe

Post

I really meant:

Code: Select all

while(--sampleFrames >= 0) 
{ 
if(Midi)
sendMidi(sFrames,status,data1,data2); 
)
and

Code: Select all

void Plugin::sendMidi(long sFrames, char status, char data1, char data2)
{
			SendableVstEvents->numEvents = 1;
			SendableMidiEventList[0].type = kVstMidiType;
			SendableMidiEventList[0].deltaFrames = sFrames;
			SendableMidiEventList[0].midiData[0] = status;
			SendableMidiEventList[0].midiData[1] = data1;
			SendableMidiEventList[0].midiData[2] = data2;
			SendableMidiEventList[0].midiData[3] = 0;
			SendableVstEvents->events[0] = (VstEvent*) &SendableMidiEventList[0];
			sendVstEventsToHost(SendableVstEvents);
}
of course!

Post

Seems to look ok, if (Midi) is not all the time "true"... :)

Is it not possible to process the audio at ones, extract all the info you need, collect the events and then send all events together to the host with one call :?: This of course assumes, that you anyhow generates the MIDI events dependant from audio information...

But I don't even know, what this is, what you're currently designing in your kitchen... :lol:

Post

I know the older Roland manuals always had the full MIDI spec, with hex charts etc.
Image

Post

Yamaha too. :)

Post

I have an old Yamaha midi implementation chart from a synth module - very useful! MIDI.h from Midi_Gain has all I need for the moment though!

I'm looking forward to sending you a working prototype when it's ready but as it's a bit of a complex thingy for a first vst and I think I will be a little while yet!!

Post Reply

Return to “DSP and Plugin Development”