MCPcopy Create free account
hub / github.com/christophhart/HISE / saveCurrentSampleMap

Method saveCurrentSampleMap

hi_scripting/scripting/api/ScriptingApi.cpp:5078–5115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5076}
5077
5078bool 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
5117bool ScriptingApi::Sampler::clearSampleMap()
5118{

Callers

nothing calls this directly

Calls 10

getCurrentFileHandlerMethod · 0.80
getMethod · 0.45
getSubDirectoryMethod · 0.45
getMainControllerMethod · 0.45
withFileExtensionMethod · 0.45
getChildFileMethod · 0.45
existsAsFileMethod · 0.45
deleteFileMethod · 0.45
createMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected