Old 01-19-2011, 05:43 AM   #1
Adam Fulara
Human being with feelings
 
Adam Fulara's Avatar
 
Join Date: Jan 2011
Posts: 48
Default Programming - && don't connect 2 conditions?

I have small midi generator:

Code:
desc:Midi Pseudo generator
in_pin:none
out_pin:none
@init
prev_beat=0;
krok=1.0/24;
@block
while(
   midirecv(offset,msg1, msg23) ? (
     midisend(offset,msg1,msg23);
   );
  );
play_state>0 ? (
  beat_position > prev_beat ? ( 
    midisend(beat_position-prev_beat,248,0);
    midisend(14 , 254,0); 
    prev_beat+=krok;
 );  
);

When you press PLAY it generates MIDI simmilar to Midi Clock (midi clock and midi ready messages).

Then in FX chains I have filter to catch both kinds of messages:

Code:
desc:miditest1a
in_pin:none
out_pin:none

@block
while(
 midirecv(offset,msg1,msg23) ? (
  ((msg1!=254) && (msg1!=248)) ? (
    midisend(offset,msg1,msg23);
  );
 );
);
I filter the 254 and 248 MIDI. The problem is, that it filters only 248 msg1 MIDI, and don't filter 254 at all, so I have still "midi msg1=254" messages in chains after that JS effect.

I use chains: first JS, second JS, Midi logger to check it.
After pressing PLAY it should be filtered. It seems like "&&" doesn't work.... ? Or I miss something.
Adam Fulara is offline   Reply With Quote
Old 01-19-2011, 05:49 AM   #2
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,376
Default

Midi loop exits when you recieve a message that doesn't fulfil the two conditions. It's a common error, catches everyone sooner or later. Try this...
Code:
desc:miditest1a
in_pin:none
out_pin:none

@block
while(
 midirecv(offset,msg1,msg23) ?
 (
   ((msg1!=254) && (msg1!=248)) ?
   (
     midisend(offset,msg1,msg23);
   );
   1; // Always return 'true'
 );
);
IXix is offline   Reply With Quote
Old 01-19-2011, 11:10 AM   #3
Adam Fulara
Human being with feelings
 
Adam Fulara's Avatar
 
Join Date: Jan 2011
Posts: 48
Default

Thank you very much.

I get it. Working.

The idea is: when midirecv get something, this IF ( "? :" ) should return "1" value to While what means that something maybe is in Midi-queue to handle, and "While" should go on. It's functional-programming-like.

Thanks, I'm newbie in JS writting, although I know C++ quite good.
Adam Fulara is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.