/[svn]/linuxsampler/trunk/src/engines/AbstractEngine.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/AbstractEngine.cpp

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

revision 2198 by iliev, Sun Jul 3 18:06:51 2011 UTC revision 2559 by schoenebeck, Sun May 18 17:38:25 2014 UTC
# Line 4  Line 4 
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *
6   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *
7   *   Copyright (C) 2009-2010 Christian Schoenebeck and Grigor Iliev        *   *   Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev        *
8     *   Copyright (C) 2013-2014 Christian Schoenebeck and Andreas Persson     *
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 26  Line 27 
27  #include "AbstractEngineChannel.h"  #include "AbstractEngineChannel.h"
28  #include "EngineFactory.h"  #include "EngineFactory.h"
29  #include "../common/global_private.h"  #include "../common/global_private.h"
30    #include "../effects/EffectFactory.h"
31    
32  namespace LinuxSampler {  namespace LinuxSampler {
33    
# Line 164  namespace LinuxSampler { Line 166  namespace LinuxSampler {
166       */       */
167      void AbstractEngine::ResetScaleTuning() {      void AbstractEngine::ResetScaleTuning() {
168          memset(&ScaleTuning[0], 0x00, 12);          memset(&ScaleTuning[0], 0x00, 12);
169            ScaleTuningChanged.raise();
170      }      }
171    
172      /**      /**
# Line 345  namespace LinuxSampler { Line 348  namespace LinuxSampler {
348       */       */
349      uint8_t AbstractEngine::GSCheckSum(const RingBuffer<uint8_t,false>::NonVolatileReader AddrReader, uint DataSize) {      uint8_t AbstractEngine::GSCheckSum(const RingBuffer<uint8_t,false>::NonVolatileReader AddrReader, uint DataSize) {
350          RingBuffer<uint8_t,false>::NonVolatileReader reader = AddrReader;          RingBuffer<uint8_t,false>::NonVolatileReader reader = AddrReader;
351          uint bytes = 3 /*addr*/ + DataSize;          uint bytes = 3 /*addr*/ + DataSize;        
         uint8_t addr_and_data[bytes];  
         reader.read(&addr_and_data[0], bytes);  
352          uint8_t sum = 0;          uint8_t sum = 0;
353          for (uint i = 0; i < bytes; i++) sum += addr_and_data[i];          uint8_t c;
354            for (uint i = 0; i < bytes; ++i) {
355                if (!reader.pop(&c)) break;
356                sum += c;
357            }
358          return 128 - sum % 128;          return 128 - sum % 128;
359      }      }
360    
# Line 358  namespace LinuxSampler { Line 363  namespace LinuxSampler {
363       *       *
364       * @param ScaleTunes - detuning of all twelve semitones (in cents)       * @param ScaleTunes - detuning of all twelve semitones (in cents)
365       */       */
366      void AbstractEngine::AdjustScale(int8_t ScaleTunes[12]) {      void AbstractEngine::AdjustScaleTuning(const int8_t ScaleTunes[12]) {
367          memcpy(&this->ScaleTuning[0], &ScaleTunes[0], 12); //TODO: currently not sample accurate          memcpy(&this->ScaleTuning[0], &ScaleTunes[0], 12);
368            ScaleTuningChanged.raise();
369        }
370        
371        void AbstractEngine::GetScaleTuning(int8_t* pScaleTunes) {
372            memcpy(pScaleTunes, &this->ScaleTuning[0], 12);
373      }      }
374    
375      uint AbstractEngine::VoiceCount() {      uint AbstractEngine::VoiceCount() {
# Line 375  namespace LinuxSampler { Line 385  namespace LinuxSampler {
385      }      }
386    
387      /**      /**
388       *  Moves pitchbend event from the general (input) event list to the engine       *  Stores the latest pitchbend event as current pitchbend scalar value.
      *  channel's event list. It will actually processed later by the  
      *  respective voice.  
389       *       *
390       *  @param pEngineChannel - engine channel on which this event occured on       *  @param pEngineChannel - engine channel on which this event occured on
391       *  @param itPitchbendEvent - absolute pitch value and time stamp of the event       *  @param itPitchbendEvent - absolute pitch value and time stamp of the event
# Line 506  namespace LinuxSampler { Line 514  namespace LinuxSampler {
514                          for (int i = 0; i < engineChannels.size(); ++i) {                          for (int i = 0; i < engineChannels.size(); ++i) {
515                              AbstractEngineChannel* pEngineChannel                              AbstractEngineChannel* pEngineChannel
516                                  = static_cast<AbstractEngineChannel*>(engineChannels[i]);                                  = static_cast<AbstractEngineChannel*>(engineChannels[i]);
517                              if (pEngineChannel->GetMidiInputPort() == itSysexEvent->pMidiInputPort) {                              Sync< ArrayList<MidiInputPort*> > midiInputs = pEngineChannel->midiInputs.front();
518                                  KillAllVoices(pEngineChannel, itSysexEvent);                              for (int k = 0; k < midiInputs->size(); ++k) {
519                                  pEngineChannel->ResetControllers();                                  if ((*midiInputs)[k] == itSysexEvent->pMidiInputPort) {
520                                        KillAllVoices(pEngineChannel, itSysexEvent);
521                                        pEngineChannel->ResetControllers();
522                                        break;
523                                    }
524                              }                              }
525                          }                          }
526                      }                      }
# Line 529  namespace LinuxSampler { Line 541  namespace LinuxSampler {
541                              if (GSCheckSum(checksum_reader, 12)) goto free_sysex_data;                              if (GSCheckSum(checksum_reader, 12)) goto free_sysex_data;
542                              #endif // CONFIG_ASSERT_GS_SYSEX_CHECKSUM                              #endif // CONFIG_ASSERT_GS_SYSEX_CHECKSUM
543                              for (int i = 0; i < 12; i++) scale_tunes[i] -= 64;                              for (int i = 0; i < 12; i++) scale_tunes[i] -= 64;
544                              AdjustScale((int8_t*) scale_tunes);                              AdjustScaleTuning((int8_t*) scale_tunes);
545                              dmsg(3,("\t\t\tNew scale applied.\n"));                              dmsg(3,("\t\t\tNew scale applied.\n"));
546                              break;                              break;
547                          }                          }
# Line 541  namespace LinuxSampler { Line 553  namespace LinuxSampler {
553                              for (int i = 0; i < engineChannels.size(); ++i) {                              for (int i = 0; i < engineChannels.size(); ++i) {
554                                  AbstractEngineChannel* pEngineChannel                                  AbstractEngineChannel* pEngineChannel
555                                      = static_cast<AbstractEngineChannel*>(engineChannels[i]);                                      = static_cast<AbstractEngineChannel*>(engineChannels[i]);
556                                  if (                                  if (pEngineChannel->midiChannel == part ||
557                                      (pEngineChannel->midiChannel == part ||                                      pEngineChannel->midiChannel == midi_chan_all)
558                                       pEngineChannel->midiChannel == midi_chan_all) &&                                  {  
559                                       pEngineChannel->GetMidiInputPort() == itSysexEvent->pMidiInputPort                                      Sync< ArrayList<MidiInputPort*> > midiInputs = pEngineChannel->midiInputs.front();
560                                  ) {                                      for (int k = 0; k < midiInputs->size(); ++k) {
561                                      try {                                          if ((*midiInputs)[k] == itSysexEvent->pMidiInputPort) {
562                                          pEngineChannel->SetMidiInstrumentMap(map);                                              try {
563                                      } catch (Exception e) {                                                  pEngineChannel->SetMidiInstrumentMap(map);
564                                          dmsg(2,("\t\t\tCould not apply MIDI instrument map %d to part %d: %s\n", map, part, e.Message().c_str()));                                              } catch (Exception e) {
565                                          goto free_sysex_data;                                                  dmsg(2,("\t\t\tCould not apply MIDI instrument map %d to part %d: %s\n", map, part, e.Message().c_str()));
566                                      } catch (...) {                                                  goto free_sysex_data;
567                                          dmsg(2,("\t\t\tCould not apply MIDI instrument map %d to part %d (unknown exception)\n", map, part));                                              } catch (...) {
568                                          goto free_sysex_data;                                                  dmsg(2,("\t\t\tCould not apply MIDI instrument map %d to part %d (unknown exception)\n", map, part));
569                                                    goto free_sysex_data;
570                                                }
571                                                break;
572                                            }
573                                      }                                      }
574                                  }                                  }
575                              }                              }

Legend:
Removed from v.2198  
changed lines
  Added in v.2559

  ViewVC Help
Powered by ViewVC