/[svn]/libgig/trunk/src/tools/korg2gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/tools/korg2gig.cpp

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

revision 2571 by schoenebeck, Wed May 21 20:33:45 2014 UTC revision 3175 by schoenebeck, Thu May 11 11:34:19 2017 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2014 Christian Schoenebeck                              *   *   Copyright (C) 2014-2017 Christian Schoenebeck                         *
4   *                      <cuse@users.sourceforge.net>                       *   *                      <cuse@users.sourceforge.net>                       *
5   *                                                                         *   *                                                                         *
6   *   This program is part of libgig.                                       *   *   This program is part of libgig.                                       *
# Line 34  Line 34 
34  # include <unistd.h>  # include <unistd.h>
35  #endif  #endif
36    
37  #include "Korg.h"  #include "../Korg.h"
38  #include "gig.h"  #include "../gig.h"
39    
40  using namespace std;  using namespace std;
41    
# Line 68  static bool beginsWith(const string& hay Line 68  static bool beginsWith(const string& hay
68  }  }
69    
70  static bool endsWith(const string& haystack, const string& needle) {  static bool endsWith(const string& haystack, const string& needle) {
71        if (haystack.size() < needle.size()) return false;
72      return haystack.substr(haystack.size() - needle.size(), needle.size()) == needle;      return haystack.substr(haystack.size() - needle.size(), needle.size()) == needle;
73  }  }
74    
# Line 214  inline string parseNumberRange(const str Line 215  inline string parseNumberRange(const str
215      stripWhiteSpace(w);      stripWhiteSpace(w);
216      stripLeftOrRightMarkerAtEnd(w);      stripLeftOrRightMarkerAtEnd(w);
217      string result = parseNumberRangeAtEnd(w, from, to);      string result = parseNumberRangeAtEnd(w, from, to);
218      if (result == w) return s; // parse error occured, return original input s      if (result == w) return s; // parse error occurred, return original input s
219      stripWhiteSpace(result);      stripWhiteSpace(result);
220      return result;      return result;
221  }  }
# Line 310  static set<DLS::range_t> collectVelocity Line 311  static set<DLS::range_t> collectVelocity
311      set<DLS::range_t> velocityRanges;      set<DLS::range_t> velocityRanges;
312      for (int i = 0; i < group.size(); ++i) {      for (int i = 0; i < group.size(); ++i) {
313          Korg::KMPInstrument* instr = group[i];          Korg::KMPInstrument* instr = group[i];
314          int iLowerKey = 0;          uint16_t iLowerKey = 0;
315          for (int k = 0; k < instr->GetRegionCount(); ++k) {          for (int k = 0; k < instr->GetRegionCount(); ++k) {
316              Korg::KMPRegion* rgn = instr->GetRegion(k);              Korg::KMPRegion* rgn = instr->GetRegion(k);
317              DLS::range_t keyRange2 = { iLowerKey, rgn->TopKey };              DLS::range_t keyRange2 = { iLowerKey, rgn->TopKey };
# Line 319  static set<DLS::range_t> collectVelocity Line 320  static set<DLS::range_t> collectVelocity
320                  int from, to;                  int from, to;
321                  string baseName = parseNumberRange(instr->Name(), from, to);                  string baseName = parseNumberRange(instr->Name(), from, to);
322                  if (baseName != instr->Name()) { // number range like "003-120" found in instrument name ...                  if (baseName != instr->Name()) { // number range like "003-120" found in instrument name ...
323                      DLS::range_t velRange = { from, to };                      DLS::range_t velRange = { uint16_t(from), uint16_t(to) };
324                      velocityRanges.insert(velRange);                      velocityRanges.insert(velRange);
325                  }                  }
326              }              }
# Line 508  static void loadKorgFile(const string& f Line 509  static void loadKorgFile(const string& f
509          exit(EXIT_FAILURE);          exit(EXIT_FAILURE);
510      } catch (...) {      } catch (...) {
511          cerr << "Failed opening input file '" << filename << "':" << endl;          cerr << "Failed opening input file '" << filename << "':" << endl;
512          cerr << "Unknown exception occured while trying to access input file." << endl;          cerr << "Unknown exception occurred while trying to access input file." << endl;
513          exit(EXIT_FAILURE);          exit(EXIT_FAILURE);
514      }      }
515  }  }
# Line 623  int main(int argc, char *argv[]) { Line 624  int main(int argc, char *argv[]) {
624                  Korg::KMPInstrument* kmpInstr = *itInstr;                  Korg::KMPInstrument* kmpInstr = *itInstr;
625                  cout << "    |---> KMP multi sample '" << kmpInstr->Name() << "'" << endl;                  cout << "    |---> KMP multi sample '" << kmpInstr->Name() << "'" << endl;
626    
627                  int iLowKey = 0;                  uint16_t iLowKey = 0;
628                  for (int k = 0; k < kmpInstr->GetRegionCount(); ++k) {                  for (int k = 0; k < kmpInstr->GetRegionCount(); ++k) {
629                      Korg::KMPRegion* kmpRegion = kmpInstr->GetRegion(k);                      Korg::KMPRegion* kmpRegion = kmpInstr->GetRegion(k);
630                      DLS::range_t keyRange = { iLowKey, kmpRegion->TopKey };                      DLS::range_t keyRange = { iLowKey, kmpRegion->TopKey };
# Line 755  int main(int argc, char *argv[]) { Line 756  int main(int argc, char *argv[]) {
756                          dimRgn->DimensionUpperLimits[iVelocityDimensionIndex] = velRange.high; // gig v3 and above                          dimRgn->DimensionUpperLimits[iVelocityDimensionIndex] = velRange.high; // gig v3 and above
757                      }                      }
758    
759                        dimRgn->FineTune = kmpRegion->Tune;
760    
761                      // assign the respective gig sample to this dimension region                      // assign the respective gig sample to this dimension region
762                      gig::Sample* gigSample = findOrCreateGigSampleForKSFRegion(kmpRegion);                      gig::Sample* gigSample = findOrCreateGigSampleForKSFRegion(kmpRegion);
763                      dimRgn->pSample = gigSample; // might be NULL (if Korg sample had zero size, or if the original instrument's internal samples were used)                      dimRgn->pSample = gigSample; // might be NULL (if Korg sample had zero size, or if the original instrument's internal samples were used)

Legend:
Removed from v.2571  
changed lines
  Added in v.3175

  ViewVC Help
Powered by ViewVC