Any chance of a quick hex & midi data lesson!
-
- KVRian
- 1325 posts since 1 Sep, 2004
Then take a closer look here.
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.
Code: Select all
char x = 144;
unsigned char y = 144;
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.
-
- KVRist
- Topic Starter
- 303 posts since 18 May, 2005
Tried unsigned char but the vst definitions are:
So why does it let me do:
?
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
};
Code: Select all
SendableMidiEventList[i].midiData[0] = 144;
-
- KVRian
- 1325 posts since 1 Sep, 2004
So why does my code work and your's not ?
ps: I know the VST spec. Very well.
ps: I know the VST spec. Very well.
-
- KVRian
- 1325 posts since 1 Sep, 2004
Code: Select all
eventMidiData0[i] = 144;
I neither know what eventMidiData0 is nor what that index i describes. So it could also be, that the problem anywhere there is.
-
- KVRist
- Topic Starter
- 303 posts since 18 May, 2005
The original code from jtrig was:
where iChan=1 this still returns 144 but signed char = 144 returns -112???
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];
-
- KVRist
- Topic Starter
- 303 posts since 18 May, 2005
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
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
-
- KVRist
- Topic Starter
- 303 posts since 18 May, 2005
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:
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
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);
}
)
Or maybe this will be fine?
Joe
-
- KVRist
- Topic Starter
- 303 posts since 18 May, 2005
I really meant:
and
of course!
Code: Select all
while(--sampleFrames >= 0)
{
if(Midi)
sendMidi(sFrames,status,data1,data2);
)
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);
}
-
- KVRian
- 1325 posts since 1 Sep, 2004
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...
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...
-
Perfect Solitude Perfect Solitude https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=63246
- Banned
- 53 posts since 29 Mar, 2005
-
- KVRian
- 1325 posts since 1 Sep, 2004
Yamaha too.
-
- KVRist
- Topic Starter
- 303 posts since 18 May, 2005
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!!
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!!