/[svn]/linuxsampler/trunk/src/engines/EngineBase.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/EngineBase.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2115 by persson, Thu Aug 12 15:36:15 2010 UTC revision 2121 by schoenebeck, Tue Sep 14 17:09:08 2010 UTC
# Line 339  namespace LinuxSampler { Line 339  namespace LinuxSampler {
339                      }                      }
340                  }                  }
341                  pVoicePool->clear();                  pVoicePool->clear();
342                    
343                    // (re)create dedicated voice audio buffers
344                    //TODO: we could optimize resource usage a bit by just allocating these dedicated voice buffers when there is at least one engine channel with FX sends, because only in this case those special buffers are used actually, but since it would usually only save couple bytes in total, its probably not worth it
345                    if (pDedicatedVoiceChannelLeft)  delete pDedicatedVoiceChannelLeft;
346                    if (pDedicatedVoiceChannelRight) delete pDedicatedVoiceChannelRight;
347                    pDedicatedVoiceChannelLeft  = new AudioChannel(0, MaxSamplesPerCycle);
348                    pDedicatedVoiceChannelRight = new AudioChannel(1, MaxSamplesPerCycle);
349              }              }
350    
351              /**              /**
# Line 857  namespace LinuxSampler { Line 864  namespace LinuxSampler {
864                  pChannel->ClearEventLists();                  pChannel->ClearEventLists();
865              }              }
866    
867                /**
868                 * Process MIDI control change events with hard coded behavior,
869                 * that is controllers whose behavior is defined independently
870                 * of the actual sampler engine type and instrument.
871                 *
872                 * @param pEngineChannel - engine channel on which the MIDI CC event was received
873                 * @param itControlChangeEvent - the actual MIDI CC event
874                 */
875              void ProcessHardcodedControllers (              void ProcessHardcodedControllers (
876                  EngineChannel*          pEngineChannel,                  EngineChannel*          pEngineChannel,
877                  Pool<Event>::Iterator&  itControlChangeEvent                  Pool<Event>::Iterator&  itControlChangeEvent
# Line 869  namespace LinuxSampler { Line 884  namespace LinuxSampler {
884                          pChannel->PortamentoTime = (float) itControlChangeEvent->Param.CC.Value / 127.0f * (float) CONFIG_PORTAMENTO_TIME_MAX + (float) CONFIG_PORTAMENTO_TIME_MIN;                          pChannel->PortamentoTime = (float) itControlChangeEvent->Param.CC.Value / 127.0f * (float) CONFIG_PORTAMENTO_TIME_MAX + (float) CONFIG_PORTAMENTO_TIME_MIN;
885                          break;                          break;
886                      }                      }
887                      case 6: { // data entry (currently only used for RPN controllers)                      case 6: { // data entry (currently only used for RPN and NRPN controllers)
888                          if (pChannel->GetMidiRpnController() == 2) { // coarse tuning in half tones                          //dmsg(1,("DATA ENTRY %d\n", itControlChangeEvent->Param.CC.Value));
889                              int transpose = (int) itControlChangeEvent->Param.CC.Value - 64;                          if (pChannel->GetMidiRpnController() >= 0) { // RPN controller number was sent previously ...
890                              // limit to +- two octaves for now                              dmsg(4,("Guess it's an RPN ...\n"));
891                              transpose = RTMath::Min(transpose,  24);                              if (pChannel->GetMidiRpnController() == 2) { // coarse tuning in half tones
892                              transpose = RTMath::Max(transpose, -24);                                  int transpose = (int) itControlChangeEvent->Param.CC.Value - 64;
893                              pChannel->GlobalTranspose = transpose;                                  // limit to +- two octaves for now
894                              // workaround, so we won't have hanging notes                                  transpose = RTMath::Min(transpose,  24);
895                              pChannel->ReleaseAllVoices(itControlChangeEvent);                                  transpose = RTMath::Max(transpose, -24);
896                                    pChannel->GlobalTranspose = transpose;
897                                    // workaround, so we won't have hanging notes
898                                    pChannel->ReleaseAllVoices(itControlChangeEvent);
899                                }
900                                // to prevent other MIDI CC #6 messages to be misenterpreted as RPN controller data
901                                pChannel->ResetMidiRpnController();
902                            } else if (pChannel->GetMidiNrpnController() >= 0) { // NRPN controller number was sent previously ...
903                                dmsg(4,("Guess it's an NRPN ...\n"));
904                                const int NrpnCtrlMSB = pChannel->GetMidiNrpnController() >> 8;
905                                const int NrpnCtrlLSB = pChannel->GetMidiNrpnController() & 0xff;
906                                dmsg(4,("NRPN MSB=%d LSB=%d Data=%d\n", NrpnCtrlMSB, NrpnCtrlLSB, itControlChangeEvent->Param.CC.Value));
907                                switch (NrpnCtrlMSB) {
908                                    case 0x1a: { // volume level of note (Roland GS NRPN)
909                                        const uint note = NrpnCtrlLSB;
910                                        const uint vol  = itControlChangeEvent->Param.CC.Value;
911                                        dmsg(4,("Note Volume NRPN received (note=%d,vol=%d).\n", note, vol));
912                                        if (note < 128 && vol < 128)
913                                            pChannel->pMIDIKeyInfo[note].Volume = VolumeCurve[vol];
914                                        break;
915                                    }
916                                    case 0x1c: { // panpot of note (Roland GS NRPN)
917                                        const uint note = NrpnCtrlLSB;
918                                        const uint pan  = itControlChangeEvent->Param.CC.Value;
919                                        dmsg(4,("Note Pan NRPN received (note=%d,pan=%d).\n", note, pan));
920                                        if (note < 128 && pan < 128) {
921                                            pChannel->pMIDIKeyInfo[note].PanLeft  = PanCurve[128 - pan];
922                                            pChannel->pMIDIKeyInfo[note].PanRight = PanCurve[pan];
923                                        }
924                                        break;
925                                    }
926                                    case 0x1d: { // reverb send of note (Roland GS NRPN)
927                                        const uint note = NrpnCtrlLSB;
928                                        const float reverb = float(itControlChangeEvent->Param.CC.Value) / 127.0f;
929                                        dmsg(4,("Note Reverb Send NRPN received (note=%d,send=%d).\n", note, reverb));
930                                        if (note < 128)
931                                            pChannel->pMIDIKeyInfo[note].ReverbSend = reverb;
932                                        break;
933                                    }
934                                    case 0x1e: { // chorus send of note (Roland GS NRPN)
935                                        const uint note = NrpnCtrlLSB;
936                                        const float chorus = float(itControlChangeEvent->Param.CC.Value) / 127.0f;
937                                        dmsg(4,("Note Chorus Send NRPN received (note=%d,send=%d).\n", note, chorus));
938                                        if (note < 128)
939                                            pChannel->pMIDIKeyInfo[note].ChorusSend = chorus;
940                                        break;
941                                    }
942                                }
943                                // to prevent other MIDI CC #6 messages to be misenterpreted as NRPN controller data
944                                pChannel->ResetMidiNrpnController();
945                          }                          }
                         // to avoid other MIDI CC #6 messages to be misenterpreted as RPN controller data  
                         pChannel->ResetMidiRpnController();  
946                          break;                          break;
947                      }                      }
948                      case 7: { // volume                      case 7: { // volume
# Line 969  namespace LinuxSampler { Line 1031  namespace LinuxSampler {
1031                          }                          }
1032                          break;                          break;
1033                      }                      }
1034                        case 98: { // NRPN controller LSB
1035                            dmsg(4,("NRPN LSB %d\n", itControlChangeEvent->Param.CC.Value));
1036                            pEngineChannel->SetMidiNrpnControllerLsb(itControlChangeEvent->Param.CC.Value);
1037                            break;
1038                        }
1039                        case 99: { // NRPN controller MSB
1040                            dmsg(4,("NRPN MSB %d\n", itControlChangeEvent->Param.CC.Value));
1041                            pEngineChannel->SetMidiNrpnControllerMsb(itControlChangeEvent->Param.CC.Value);
1042                            break;
1043                        }
1044                      case 100: { // RPN controller LSB                      case 100: { // RPN controller LSB
1045                            dmsg(4,("RPN LSB %d\n", itControlChangeEvent->Param.CC.Value));
1046                          pEngineChannel->SetMidiRpnControllerLsb(itControlChangeEvent->Param.CC.Value);                          pEngineChannel->SetMidiRpnControllerLsb(itControlChangeEvent->Param.CC.Value);
1047                          break;                          break;
1048                      }                      }
1049                      case 101: { // RPN controller MSB                      case 101: { // RPN controller MSB
1050                            dmsg(4,("RPN MSB %d\n", itControlChangeEvent->Param.CC.Value));
1051                          pEngineChannel->SetMidiRpnControllerMsb(itControlChangeEvent->Param.CC.Value);                          pEngineChannel->SetMidiRpnControllerMsb(itControlChangeEvent->Param.CC.Value);
1052                          break;                          break;
1053                      }                      }

Legend:
Removed from v.2115  
changed lines
  Added in v.2121

  ViewVC Help
Powered by ViewVC