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

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

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

revision 3081 by schoenebeck, Thu Dec 15 12:47:45 2016 UTC revision 3082 by schoenebeck, Mon Jan 9 18:39:35 2017 UTC
# Line 32  Line 32 
32  #include "../../common/File.h"  #include "../../common/File.h"
33  #include "../../common/Path.h"  #include "../../common/Path.h"
34  #include "LookupTable.h"  #include "LookupTable.h"
35    #include "../../common/global_private.h"
36    
37  namespace sfz  namespace sfz
38  {  {
# Line 66  namespace sfz Line 67  namespace sfz
67      }      }
68    
69      /////////////////////////////////////////////////////////////      /////////////////////////////////////////////////////////////
70      // class optional      // class Script
71    
72      const optional_base::nothing_t optional_base::nothing;      Script::Script(LinuxSampler::Path path) : m_path(path) {
73        }
74    
75        Script::Script(String path) : m_path(LinuxSampler::Path::fromUnknownFS(path)) {
76        }
77    
78        Script::~Script() {
79        }
80    
81        String Script::Name() const {
82            return m_path.getName();
83        }
84    
85        Script::Language_t Script::Language() {
86            return LANGUAGE_NKSP;
87        }
88    
89        String Script::GetSourceCode() {
90            std::ifstream f(m_path.toNativeFSPath().c_str());
91            std::string s;
92            // reserve required space on string object
93            f.seekg(0, std::ios::end);
94            s.reserve(f.tellg());
95            f.seekg(0, std::ios::beg);
96            // read entire content from file and assign it to string object
97            s.assign((std::istreambuf_iterator<char>(f)),
98                      std::istreambuf_iterator<char>());
99            return s;
100        }
101    
102      /////////////////////////////////////////////////////////////      /////////////////////////////////////////////////////////////
103      // class Articulation      // class Articulation
# Line 305  namespace sfz Line 334  namespace sfz
334          off_mode = OFF_FAST;          off_mode = OFF_FAST;
335    
336          // sample player          // sample player
337          count.unset();          count = optional<int>::nothing;
338          delay.unset(); delay_random.unset();          delay = optional<float>::nothing;
339          delay_beats.unset(); stop_beats.unset();          delay_random = optional<float>::nothing;
340          delay_samples.unset();          delay_beats = optional<int>::nothing;
341            stop_beats = optional<int>::nothing;
342            delay_samples = optional<int>::nothing;
343          end = 0;          end = 0;
344          loop_crossfade.unset();          loop_crossfade = optional<float>::nothing;
345          offset.unset(); offset_random.unset();          offset = optional<uint>::nothing;
346            offset_random = optional<int>::nothing;
347          loop_mode = LOOP_UNSET;          loop_mode = LOOP_UNSET;
348          loop_start.unset(); loop_end.unset();          loop_start = optional<int>::nothing;
349          sync_beats.unset(); sync_offset.unset();          loop_end = optional<int>::nothing;
350            sync_beats = optional<int>::nothing;
351            sync_offset = optional<int>::nothing;
352    
353          // amplifier          // amplifier
354          volume = 0;          volume = 0;
# Line 361  namespace sfz Line 395  namespace sfz
395    
396          // filter          // filter
397          fil_type = LPF_2P;          fil_type = LPF_2P;
398          cutoff.unset();          cutoff = optional<float>::nothing;
399          cutoff_chanaft = 0;          cutoff_chanaft = 0;
400          cutoff_polyaft = 0;          cutoff_polyaft = 0;
401          resonance = 0;          resonance = 0;
# Line 371  namespace sfz Line 405  namespace sfz
405          fil_random = 0;          fil_random = 0;
406    
407          fil2_type = LPF_2P;          fil2_type = LPF_2P;
408          cutoff2.unset();          cutoff2 = optional<float>::nothing;
409          cutoff2_chanaft = 0;          cutoff2_chanaft = 0;
410          cutoff2_polyaft = 0;          cutoff2_polyaft = 0;
411          resonance2 = 0;          resonance2 = 0;
# Line 1146  namespace sfz Line 1180  namespace sfz
1180                                    
1181                  continue;                  continue;
1182              }              }
1183                // script=path/to/scriptfile
1184                else if (line.find("script") == 0) {
1185                    size_t eq = line.find_first_of("=");
1186                    if (eq == std::string::npos) {
1187                        std::cerr << "sfz error: opcode 'script' misses '=' character\n";
1188                        continue;
1189                    }
1190                    std::string value = trim( line.substr(eq+1, std::string::npos) );
1191                    if (value.empty()) {
1192                        std::cerr << "sfz error: empty path assigned to opcode 'script'\n";
1193                        continue;
1194                    }
1195                    LinuxSampler::Path path = LinuxSampler::Path::fromUnknownFS(value);
1196                    if (!currentDir.empty() && !path.isAbsolute())
1197                        path = LinuxSampler::Path::fromUnknownFS(currentDir) + path;
1198                    LinuxSampler::File file(path);
1199                    if (!file.Exist()) {
1200                        std::cerr << "sfz error: script file '" << value << "' does not exist\n";
1201                        continue;
1202                    }
1203                    if (!file.IsFile()) {
1204                        std::cerr << "sfz error: script '" << value << "' is not a file\n";
1205                        continue;
1206                    }
1207                    Script script(path);
1208                    _instrument->scripts.push_back(script);
1209                }
1210    
1211              // DEFINITION              // DEFINITION
1212              std::stringstream linestream(line);              std::stringstream linestream(line);

Legend:
Removed from v.3081  
changed lines
  Added in v.3082

  ViewVC Help
Powered by ViewVC