Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 10-21-2019, 03:45 AM   #1
pll
Human being with feelings
 
Join Date: Oct 2019
Posts: 3
Default VST3 Program Change: 0 never transmitted (FIXED)

Hi,

When trying to implement the Program Change support on my vst3 plugin, I find the following issue:

* MSB message value between 0 and 127 are transmitted by the DAW
* Program Change value 0 is never transmitted by the DAW
* Program Change value between 1 and 127 are transmitted by the DAW

It seems to me that Program Change should be able to send 128 values [0, 127] or [1, 128]

Do you have any information ?
pll is offline   Reply With Quote
Old 10-21-2019, 03:52 AM   #2
EvilDragon
Human being with feelings
 
EvilDragon's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 24,859
Default

Yeah, should be 0-127.
EvilDragon is offline   Reply With Quote
Old 10-21-2019, 03:59 AM   #3
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 16,501
Default

Here is the code on our side:

Code:
                  int paramid=VST3_GetProgChgParamForUnit(m_vst3->m_controller, unitid);
                  if (paramid >= 0)
                  {
                    int progidx=mevt->midiData[1];
                    int progcnt=0;

                    int ui, un=uinfo->getUnitCount();
                    for (ui=0; ui < un; ++ui)
                    {
                      UnitInfo tuinfo={0};
                      uinfo->getUnitInfo(ui, tuinfo);
                      if (tuinfo.id == unitid)
                      {
                        int li, ln=uinfo->getProgramListCount();
                        for (li=0; li < ln; ++li)
                        {
                          ProgramListInfo pinfo={0};
                          uinfo->getProgramListInfo(li, pinfo);
                          if (pinfo.id == tuinfo.programListId)
                          {
                            progcnt=pinfo.programCount;
                            break;
                          }
                        }
                        break;
                      }
                    }

                    double val=m_vst3->m_controller->plainParamToNormalized(paramid, progidx);
                    if (val != (double)progidx && val >= 0.0 && val <= 1.0)
                    {
                      // plainParamToNormalized seemed to do something, accept
                    }
                    else if (progcnt > 0 && progidx >= 0 && progidx < progcnt)
                    {
                      val=(double)progidx/(double)progcnt;
                    }
                    else
                    {
                      val=-1.0;
                    }
                    if (val >= 0.0)
                    {
                      int paramidx=m_vst3->GetParamIdx(paramid);
                      VST3_SetParameter(effect, paramidx, val, 0);
                    }
                  }
There is some flexible support in there for plugins not implementing plainParamToNormalized for the program change parameter, and the return from that function will get ignored for the 0th program. But it looks to me like the only way the zero would not get transmitted at all is if the plugin also returns zero via ProgramListInfo.programCount.
schwa is offline   Reply With Quote
Old 10-29-2019, 08:55 AM   #4
pll
Human being with feelings
 
Join Date: Oct 2019
Posts: 3
Default

Here is what I suspect to happened when I receive a Program Change with value 0

int progidx=mevt->midiData[1] => 0
plainParamToNormalized -> [0, 1] => 0
so the check (val != (double)progidx) fail.

Then, the progCnt is 0 on my side, and I go to the error case.

There is 2 issues:
- I should change progCnt on my side to ensure the progCnt is not null.
- I should not pass in 2 differents cases when value is 0 and value is !=0, I think you should change the first check
pll is offline   Reply With Quote
Old 10-29-2019, 03:58 PM   #5
ivansc
Human being with feelings
 
Join Date: Aug 2007
Location: Near Cambridge UK and Near Questembert, France
Posts: 22,756
Default

As rule of thumb, some manufacturers use 0 to 127, some use 1 to 128.

This can often lead to fun situations like the one you appear to be in right now. Fortunately, Schwa has your back.
__________________
Ici on parles Franglais
ivansc is offline   Reply With Quote
Old 10-29-2019, 04:27 PM   #6
EvilDragon
Human being with feelings
 
EvilDragon's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 24,859
Default

Actually AFAIK they all use 0-127 internally, but sometimes they display the values as 1-128 (since humans start counting from 1, heh).
EvilDragon is offline   Reply With Quote
Old 10-29-2019, 04:52 PM   #7
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 16,278
Default

Quote:
Originally Posted by EvilDragon View Post
humans start counting from 1.
Finally I know what is wrong. I am not human

-Michael
mschnell is online now   Reply With Quote
Old 11-22-2019, 03:20 AM   #8
pll
Human being with feelings
 
Join Date: Oct 2019
Posts: 3
Default

Quote:
Originally Posted by schwa View Post
and the return from that function will get ignored for the 0th program.
Could you explain why you ignore the 0th program ?
pll 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 02:25 PM.


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