| 5076 | } |
| 5077 | |
| 5078 | bool ScriptingApi::Sampler::saveCurrentSampleMap(String relativePathWithoutXml) |
| 5079 | { |
| 5080 | ModulatorSampler *s = static_cast<ModulatorSampler*>(sampler.get()); |
| 5081 | |
| 5082 | if (s == nullptr) |
| 5083 | { |
| 5084 | reportScriptError("setAttribute() only works with Samplers."); |
| 5085 | RETURN_IF_NO_THROW(false); |
| 5086 | } |
| 5087 | |
| 5088 | if (s->getNumSounds() == 0) |
| 5089 | { |
| 5090 | debugToConsole(s, "Skipping creation of empty samplemap"); |
| 5091 | return false; |
| 5092 | } |
| 5093 | |
| 5094 | if (auto sm = s->getSampleMap()) |
| 5095 | { |
| 5096 | auto sampleMapsDirectory = s->getMainController()->getCurrentFileHandler().getSubDirectory(FileHandlerBase::SampleMaps); |
| 5097 | |
| 5098 | auto targetFile = sampleMapsDirectory.getChildFile(relativePathWithoutXml).withFileExtension("xml"); |
| 5099 | |
| 5100 | if (targetFile.existsAsFile()) |
| 5101 | { |
| 5102 | debugToConsole(s, "Overwriting file " + targetFile.getFullPathName()); |
| 5103 | targetFile.deleteFile(); |
| 5104 | targetFile.create(); |
| 5105 | } |
| 5106 | else |
| 5107 | { |
| 5108 | targetFile.create(); |
| 5109 | } |
| 5110 | |
| 5111 | return sm->save(targetFile); |
| 5112 | } |
| 5113 | else |
| 5114 | return false; |
| 5115 | } |
| 5116 | |
| 5117 | bool ScriptingApi::Sampler::clearSampleMap() |
| 5118 | { |
nothing calls this directly
no test coverage detected