Old 01-28-2020, 04:20 PM   #1
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,470
Default MIDI display patchname in "embedded" window

Maybe somebody would like to test this before I upload it to ReaPack.
- Select a patchname file and a Midi channel
In Non-embedded mode you'll see the start of file content
- route a midi stream to the plugin
In Embedded mode you'll see the current patch name.


Code:
desc:Midi Display Patchname

slider1:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,all}>Input Channel
slider3:/Display Patchname:none:Patchname File
slider4:0<0,1,1{Current,File}>Display

@init
maxlines = 1023;
file_old = -1;
statPC   = $xC0;
curpatch = -1;

@slider
filenr_old != slider3 ? (  // Multiple file use would kill the programm permanently !
  
  filenr_old = slider3;

  offset = 0;
  while (offset < maxlines) (
    strcpy (offset, "");
    offset += 1;  
  );  
  
  offset = 0;
  lines = 0;
  
  handle=file_open(slider3);
//  file_string(handle,offset);
  while( offset < maxlines ) (
    file_string(handle,#s);

    c = 0;
    strlen(#s) > 0 ? (
//      #s = strcpy(#, offset);
      c = str_getchar(#s, 0, 'c');     
/* 
      offset == 0 ? (
        ___0 = c;
       ) : offset == 1 ? (
        ___1 = c;
       ) : offset == 2 ? (
        ___2 = c;
       ) : offset == 3 ? (
        ___3 = c;
       ) : offset == 4 ? (
        ___4 = c;
       ) : offset == 5 ? (
        ___5 = c;
      );   
*/            
      c1 = -1;
      c2 = -1;
      c < 0x30 || c > 0x39 ? (
        c = -1 ;
       ) : ( 
        c1 = str_getchar(#s, 1, 'c');     
        c1 < 0x30 || c1 > 0x39 ? (
          c1 = -1 ;
         ) : ( 
          c2 = str_getchar(#s, 2, 'c');     
          c2 < 0x30 || c2 > 0x39 ? (
            c2 = -1 ;
          );  
        );
      );
    );  
    c > 0 ? (
      nn = c - 0x30;
      c1 > 0 ? (
        nn = nn * 10 + c1 -0x30;
        c2 > 0 ? (
          nn = nn * 10 + c2 -0x30;
        );
      );    
      c2 > 0 ? (
        strcpy_from(#s, #s, 4);
       ) :  c1 > 0 ? (
        strcpy_from(#s, #s, 3);
       ) : (
        strcpy_from(#s, #s, 2);
      );  

      offset == 0 ? (
        ___0 = nn;
       ) : offset == 1 ? (
        ___1 = nn;
       ) : offset == 2 ? (
        ___2 = nn;
       ) : offset == 3 ? (
        ___3 = nn;
       ) : offset == 4 ? (
        ___4 = nn;
       ) : offset == 5 ? (
        ___5 = nn;
      );   

      
//      strcpy(offset, #s);
      nn <= maxlines ? (      
        strcpy(nn, #s);
      );
      offset+=1;   
      lines +=1;
     ) : c == 0 ? ( //
      offset = 1000000; 
    );
  );
    
  file_close(file);
);  
inChannel = slider1;
display   = slider4


@block
while (midirecv(offset, msg1, msg23))  (  
    // Extract message type and channel
  status = msg1 & $xF0;
  channel = msg1 & $x0F;
      
    // Is it on our channel?
  channel == inChannel ?  (
    // Is it a note on event?
    status == statPC ? (
      curpatch = msg23 & 0x7F;
    );
  );
  midisend(offset, msg1, msg23);
);  

@gfx 650 450  

  //display file
//  textw = gfx_texth * 0.6;
  display && gfx_w > 300 ? (
    gfx_r=gfx_g=gfx_b=0; gfx_a=1;
    gfx_x=gfx_y=0;
    gfx_rectto(gfx_w,gfx_h);
  
    gfx_setfont(2,#font,18);
    gfx_x=10;
    gfx_y=10;
    gfx_r=gfx_g=gfx_b=1;
    gfx_printf("lines: %d", lines);
    handle >= 0 & lines ? (
      _row = 0;
      _n   = 0;
      loop(maxlines,
        gfx_x=10;
        gfx_y=40 + 20 * _row;
        #s = strcpy(#, _n);
        gfx_r=gfx_g=gfx_b=1;
//        gfx_drawstr(#s);
        strlen(#s) ? (
          gfx_printf("%d:%s", _n, #s);
          _row += 1;
        );
        _n += 1;
      );  
     ) : ( 
      gfx_x=10;
      gfx_y=40;
      gfx_r=1;gfx_g=0;gfx_b=0;
      gfx_drawstr("No appropriate *.txt file in   >>>>  .../Display Patchname  <<<<");    
    );
   ) : ( 
    gfx_r=0; gfx_g=gfx_b=0.5; gfx_a=1;
    gfx_x=gfx_y=0;
    gfx_rectto(gfx_w,gfx_h);
  
    gfx_setfont(2,#font,18);

    gfx_r=1; gfx_g=gfx_b=1;
    strcpy_substr(#_s1,curpatch,0,10);  
    strcpy_substr(#_s2,curpatch,10,10);  
    strcpy_substr(#_s3,curpatch,20,10);  
    gfx_x=0;
    gfx_y=0;
    gfx_drawstr(#_s1);
    gfx_x=0;
    gfx_y=14;
    gfx_drawstr(#_s2);
    gfx_x=0;
    gfx_y=28;
    gfx_drawstr(#_s3);
  );

Here a patch name file to be loaded in the Data/Display Patchname directory as e.g. GM.txt (very similar to a reabank file):
Code:
// .reabank files define MIDI bank/program (patch) information
// for specific hardware or software devices
//
// A bank entry lists the MSB, LSB, and bank name
// for all the patches that follow, until the next bank entry.
//
Bank 121 0 General MIDI
//
// A program entry simply lists the program number and patch name.
//
0 Acoustic Grand Piano
1 Bright Acoustic Piano
2 Electric Grand Piano
3 Honky-tonk Piano
4 Electric Piano 1
5 Electric Piano 2
6 Harpsichord
7 Clavinet
8 Celesta
9 Glockenspiel
10 Music Box
11 Vibraphone
12 Marimba
13 Xylophone
14 Tubular Bells
15 Dulcimer
16 Drawbar Organ
17 Percussive Organ
18 Rock Organ
19 Church Organ
20 Reed Organ
21 Accordion
22 Harmonica
23 Tango Accordion
24 Acoustic Guitar (nylon)
25 Acoustic Guitar (steel)
26 Electric Guitar (jazz)
27 Electric Guitar (clean)
28 Electric Guitar (muted)
29 Overdriven Guitar
30 Distortion Guitar
31 Guitar harmonics
32 Acoustic Bass
33 Electric Bass (finger)
34 Electric Bass (pick)
35 Fretless Bass
36 Slap Bass 1
37 Slap Bass 2
38 Synth Bass 1
39 Synth Bass 2
40 Violin
41 Viola
42 Cello
43 Contrabass
44 Tremolo Strings
45 Pizzicato Strings
46 Orchestral Harp
47 Timpani
48 String Ensemble 1
49 String Ensemble 2
50 Synth Strings 1
51 Synth Strings 2
52 Choir Aahs
53 Voice Oohs
54 Synth Voice
55 Orchestra Hit
56 Trumpet
57 Trombone
58 Tuba
59 Muted Trumpet
60 French Horn
61 Brass Section
62 Synth Brass 1
63 Synth Brass 2
64 Soprano Sax
65 Alto Sax
66 Tenor Sax
67 Baritone Sax
68 Oboe
69 English Horn
70 Bassoon
71 Clarinet
72 Piccolo
73 Flute
74 Recorder
75 Pan Flute
76 Blown Bottle
77 Shakuhachi
78 Whistle
79 Ocarina
80 Lead 1 (square)
81 Lead 2 (sawtooth)
82 Lead 3 (calliope)
83 Lead 4 (chiff)
84 Lead 5 (charang)
85 Lead 6 (voice)
86 Lead 7 (fifths)
87 Lead 8 (bass + lead)
88 Pad 1 (new age)
89 Pad 2 (warm)
90 Pad 3 (polysynth)
91 Pad 4 (choir)
92 Pad 5 (bowed)
93 Pad 6 (metallic)
94 Pad 7 (halo)
95 Pad 8 (sweep)
96 FX 1 (rain)
97 FX 2 (soundtrack)
98 FX 3 (crystal)
99 FX 4 (atmosphere)
100 FX 5 (brightness)
101 FX 6 (goblins)
102 FX 7 (echoes)
103 FX 8 (sci-fi)
104 Sitar
105 Banjo
106 Shamisen
107 Koto
108 Kalimba
109 Bag pipe
110 Fiddle
111 Shanai
112 Tinkle Bell
113 Agogo
114 Steel Drums
115 Woodblock
116 Taiko Drum
117 Melodic Tom
118 Synth Drum
119 Reverse Cymbal
120 Guitar Fret Noise
121 Breath Noise
122 Seashore
123 Bird Tweet
124 Telephone Ring
125 Helicopter
126 Applause
127 Gunshot
-Michael

Last edited by mschnell; 01-28-2020 at 04:26 PM.
mschnell is offline   Reply With Quote
Old 01-28-2020, 05:51 PM   #2
billybuck
Human being with feelings
 
Join Date: Jan 2020
Posts: 54
Default

Wow! It would be great to have a way to route this into the track name, for example:

[abbreviated instrument or effect name]:[abbreviated patch name or number]

For those cases when A) Reaper or the VST "forgets" the patch settings or B) when you're using one instance of a VSTi and recording output audio with different presets to child tracks to avoid running multiple instances of the VSTi.
billybuck is online now   Reply With Quote
Old 01-29-2020, 12:02 AM   #3
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,470
Default

I don't suppose the track name display is supposed to be dynamic.

-Michael
mschnell is offline   Reply With Quote
Old 01-29-2020, 02:40 PM   #4
dave_t
Human being with feelings
 
dave_t's Avatar
 
Join Date: Jan 2016
Posts: 91
Default

This is great! I see you replied to my other thread about displaying patch names more prominently, thanks!

I'm trying it out. Using a generic GM list (the GM.reabank file renamed to GM.txt), I can get patch names to display, and to respond to program change messages.

The plugin is displaying names from GM Bank 1, although there is a GM bank 0 in the text file.

The name of the patch seems to wrap around after 10 characters (see patch2.jpg, attached), even though there's lots of room on the display

Also, I messed with the font settings, and I can get the font bigger, but it still wraps around after 10 characters, and the the lines overlap because the font is bigger but the line spacing hasn't changed (see patch.jpg, attached).

I don't know enough about plugins to know which settings would affect these issues.

But yeah, great work, thank you, exactly what I'm looking for
Attached Images
File Type: jpg patch.jpg (58.7 KB, 40 views)
File Type: jpg patch2.jpg (42.5 KB, 33 views)
dave_t is offline   Reply With Quote
Old 01-29-2020, 07:40 PM   #5
dave_t
Human being with feelings
 
dave_t's Avatar
 
Join Date: Jan 2016
Posts: 91
Default

Trying it out again at home on REAPER 6.03

Embedding the plugin in the TCP looks great, but still have the same issues with the text wrapping around after 10 characters

Also, when moving the program change values steadily up by one, the program names displayed seem to jump around between the GM banks. I don't think I'm sending any bank change messages
dave_t is offline   Reply With Quote
Old 01-30-2020, 02:49 PM   #6
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,470
Default

Quote:
Originally Posted by dave_t View Post
I'm trying it out. Using a generic GM list (the GM.reabank file renamed to GM.txt), I can get patch names to display, and to respond to program change messages.
The plugin is displaying names from GM Bank 1, although there is a GM bank 0 in the text file....
The initial version needs a file with a single bank, and no empty lines,

I already did an improved version that correctly uses a renamed reabank file, reads multiple banks and responds to bank select Midi CC messages. It also performs an improved improved line wrapping. Currently I am checking out selectable font sizes...

-Michael
mschnell is offline   Reply With Quote
Old 01-31-2020, 12:19 PM   #7
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,470
Default

Improved version, now
- reads standard reabank file renamed to *.txt
- supports multiple banks (but only low byte of bank command, and Bank lines in the file need to exactly use he format of GM.reeasbank)
- selectable Font size
- attempting to split lines between words ...

Please Test !

-Michael
Code:
// ToDo: Bank hight
// ToDo: decently decode bank string
// ToDo; Set Font Size
// ToDo



desc:Midi Display Patchname

slider1:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,all}>Input Channel
slider2:1<0,2,1{12,18,24}>Font size
slider3:/Display Patchname::Patchname File
slider4:0<0,1,1{Current,File}>Display

@init
maxlines  = 2048;
file_old  = -1;
statPC    = $xC0;
statCC    = $xB0;
CC_BS_LSB = $x20;
cur_patch = -1;
cur_bank  = 0;
old_patch = -2;
old_bank  = -1;

@slider
filenr_old != slider3 ? (  // Multiple file use would kill the programm permanently !
  
  filenr_old = slider3;

  offset = 0;
  while (offset < maxlines) (
    strcpy (offset, "");
    offset += 1;  
  );  
  
  offset = 0;
  lines  = 0;
  bank   = 0;
  
  handle=file_open(slider3);
//  file_string(handle,offset);
  while( offset < maxlines ) (
    file_string(handle,#s);
    file_avail(handle) ? (

      c = 0;
      strlen(#s) > 0 ? (
//        #s = strcpy(#, offset);
        c = str_getchar(#s, 0, 'c');     
        c0 = c;
/* 
        offset == 0 ? (
          ___0 = c;
         ) : offset == 1 ? (
          ___1 = c;
         ) : offset == 2 ? (
          ___2 = c;
         ) : offset == 3 ? (
          ___3 = c;
         ) : offset == 4 ? (
          ___4 = c;
         ) : offset == 5 ? (
          ___5 = c;
        );   
*/            
        c1 = -1;
        c2 = -1;
        c0 < 0x30 || c0 > 0x39 ? (
          c0 = -1 ;
         ) : ( 
          c1 = str_getchar(#s, 1, 'c');     
          c1 < 0x30 || c1 > 0x39 ? (
            c1 = -1 ;
           ) : ( 
            c2 = str_getchar(#s, 2, 'c');     
            c2 < 0x30 || c2 > 0x39 ? (
              c2 = -1 ;
            );  
          );
        );
      );  
      c0 > 0 ? (
        nn = c0 - 0x30;
        c1 > 0 ? (
          nn = nn * 10 + c1 -0x30;
          c2 > 0 ? (
            nn = nn * 10 + c2 -0x30;
          );
        );    
        c2 > 0 ? (
          strcpy_from(#s, #s, 4);
         ) :  c1 > 0 ? (
          strcpy_from(#s, #s, 3);
         ) : (
          strcpy_from(#s, #s, 2);
        );  

/*
        offset == 0 ? (
          ___0 = nn;
         ) : offset == 1 ? (
          ___1 = nn;
         ) : offset == 2 ? (
          ___2 = nn;
         ) : offset == 3 ? (
          ___3 = nn;
         ) : offset == 4 ? (
          ___4 = nn;
         ) : offset == 5 ? (
          ___5 = nn;
        );   
*/
      
//      strcpy(offset, #s);
        nn += 128 * bank;
        nn <= maxlines ? (      
          strcpy(nn, #s);
        );
        offset+=1;   
        lines +=1;
       ) : c == 'B' ? ( 
        c1 = str_getchar(#s, 9, 'c');     
        bank = c1 - 0x30;;
      );  
     ) : (
      offset = 1000000;       
    );
  );
  file_close(handle);
);  
inChannel = slider1;
display   = slider4;
fontsize  = slider2;

@block
while (midirecv(offset, msg1, msg23))  (  
    // Extract message type and channel
  status = msg1 & $xF0;
  channel = msg1 & $x0F;
      
    // Is it on our channel?
  (channel == inChannel) || (inChannel > 15)?  (
    // Is it a note on event?
    status == statPC ? (
      cur_patch = msg23 & 0x7F;
     ) :  status == statCC ? (
      msg23 & 0xFF == CC_BS_LSB ? (
        cur_bank = msg23 >> 8;
      );
    );
  );
  midisend(offset, msg1, msg23);
);  

@gfx 650 450  

  //display file
//  textw = gfx_texth * 0.6;
  display && gfx_w > 300 ? (
    gfx_r=gfx_g=gfx_b=0; gfx_a=1;
    gfx_x=gfx_y=0;
    gfx_rectto(gfx_w,gfx_h);
  
    gfx_setfont(2,#font,18);
    gfx_x=10;
    gfx_y=10;
    gfx_r=gfx_g=gfx_b=1;
    gfx_printf("lines: %d", lines);
//    handle >= 0 && lines ? (
    lines ? (
      _row = 0;
      _n   = 0;
      loop(maxlines,
        gfx_x=10;
        gfx_y=40 + 20 * _row;
        #s = strcpy(#, _n);
        gfx_r=gfx_g=gfx_b=1;
//        gfx_drawstr(#s);
        strlen(#s) ? (
          gfx_printf("%d:%s", _n, #s);
          _row += 1;
        );
        _n += 1;
      );  
     ) : ( 
      gfx_x=10;
      gfx_y=40;
      gfx_r=1;gfx_g=0;gfx_b=0;
      gfx_drawstr("No appropriate *.txt file in   >>>>  .../Display Patchname  <<<<");    
    );
   ) : ( 
    gfx_w > 300 ? old_bank = -1;                                      // for testing
    (old_bank != cur_bank) ||( old_patch != cur_patch) ? ( 
      fontsize == 0 ? (
        _fontsize   = 12;
        _fontheight = 11;
        maxchars    = 17;
       ) : fontsize == 1 ? (
        _fontsize   = 18;
        _fontheight = 14;
        maxchars    = 10;
       ) : ( 
        _fontsize   = 24; 
        _fontheight = 20;
        maxchars    = 6;
      ); 
      old_bank  = cur_bank;
      old_patch = cur_patch; 
      gfx_r=0; gfx_g=gfx_b=0.5; gfx_a=1;
      gfx_x=gfx_y=0;
      gfx_rectto(gfx_w,gfx_h);
  
      gfx_setfont(2,#font,_fontsize);

      gfx_r=1; gfx_g=gfx_b=1;
      _n = cur_patch + 128 * cur_bank;
/*    
      strcpy_substr(#_s1,_n,0,10);  
      strcpy_substr(#_s2,_n,10,10);  
      strcpy_substr(#_s3,_n,20,10);  
*/  
      lastb = 5;
      _maxb = maxchars - lastb;
      _len = strlen(_n) - 2;    // Why -2 ???
      _ok  = 0;
      while (_ok < 2) (
      #_s1 = "";
      #_s2 = "";
      #_s3 = "";
      _i   =  0;
      _o   =  0;
      _bi  = 0;
      _bo  = 0;
      _s1  = 0;
      _s2  = 0;
      _bc  = 0;
      _s   = 1;
      while (_i < _len) (
        _c = str_getchar(_n, _i, 'c');     
        _s == 1 ? (
          str_setchar(#_s1,_o, _c, 'c');
         ) : _s == 2 ? (
          str_setchar(#_s2,_o, _c, 'c');
         ) : _s == 3 ? (
          str_setchar(#_s3,_o, _c, 'c');
        );  
        (_c == ' ')  || /*(_c == '-') ||*/ (_c == '_') ? (
          _bi = _i;
          _bo = _o;
          _bc += 1;
        );
        _o += 1;
        _o > maxchars ? (
          bo += 1;
          (_bo > _maxb) && (_bo != maxchars) ? (
            while (_bo <= maxchars) (
              _s == 1 ? (
                str_setchar(#_s1,_bo, ' ', 'c');
                _s1 = 1;
               ) : _s == 2 ? (
                str_setchar(#_s2,_bo, ' ', 'c');
                _s2 = 1;
               ) : _s == 3 ? (
                str_setchar(#_s3,_bo, ' ', 'c');
              );  
              _bo += 1;
              _i -= 1;
            );
            _i += 1;
          );
          _o = 0;
          _s += 1;
        );  
        _i += 1;        
      );

      (_s < 3) /* && strlen(#_s3) == 0 */? (
        !_s1 ? (
          _bc && (_bc < 3) ? (
            _maxb = -1;
            _ok += 1;
           ) : ( 
            _ok = 2; 
          );
         ) : ( 
          _ok = 2; 
        );
       ) : (
        _ok = 2;
      );  
      
//      _ok = 1;
      
      );
  
      gfx_x = 0;
      gfx_y = 0;
      gfx_drawstr(#_s1);
      gfx_x = 0;
      gfx_y += _fontheight;
      gfx_drawstr(#_s2);
      gfx_x = 0;
      gfx_y += _fontheight;
      gfx_drawstr(#_s3);
      
      ___1 = strlen(#_s1);
      ___2 = strlen(#_s2);
      ___3 = strlen(#_s3);
      
    );
  );
mschnell is offline   Reply With Quote
Old 01-31-2020, 12:44 PM   #8
dave_t
Human being with feelings
 
dave_t's Avatar
 
Join Date: Jan 2016
Posts: 91
Default

Excellent! Got it working nicely now. I tinkered with the maximun font size, and the maximum characters per line, and now I've got a nice legible display of my hardware synth's presets when I'm using my MIDI controller keyboard.

Great work!

Dave_t
dave_t is offline   Reply With Quote
Old 02-09-2020, 11:15 PM   #9
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,470
Default

Now available on Reapack -> "Midi Display Patch Name"
-Michael
mschnell is offline   Reply With Quote
Old 02-11-2020, 09:34 AM   #10
dave_t
Human being with feelings
 
dave_t's Avatar
 
Join Date: Jan 2016
Posts: 91
Default

I can't seem to find it using Reapack - maybe I don't have the right repository installed?

Dave_t
dave_t is offline   Reply With Quote
Old 02-11-2020, 11:31 AM   #11
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,470
Default

Its in the ReaTeam repository that is installed by default.

Maybe you need to do ReaPack -> Synchronize Packages.
-Michael
mschnell 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 09:22 PM.


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