GetDunne Wiki

Notes from the desk of Shane Dunne, software development consultant

User Tools

Site Tools


the_plugin_processor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
the_plugin_processor [2017/08/30 17:37]
shane
the_plugin_processor [2017/08/30 17:47] (current)
shane
Line 89: Line 89:
 </code> </code>
 This code changes the //pParams// pointer inside the shared //SynthSound// object, which propagates the change to subsequently-played notes (we don't attempt to change currently-sounding notes in response to program changes), then calls //sendChangeMessage()// to notify the GUI editor, so it can update its display accordingly. This code changes the //pParams// pointer inside the shared //SynthSound// object, which propagates the change to subsequently-played notes (we don't attempt to change currently-sounding notes in response to program changes), then calls //sendChangeMessage()// to notify the GUI editor, so it can update its display accordingly.
 +
 +===== changeProgramName() =====
 +
 +The //changeProgramName()// function gets called whenever the user edits the name of the current preset through the plugin host:
 +<code cpp>
 +void VanillaJuceAudioProcessor::changeProgramName (int index, const String& newName)
 +{
 +    newName.copyToUTF8(programBank[index].programName, kMaxProgramNameLength);
 +    sendChangeMessage();
 +}
 +</code>
 +
 +The present VanillaJuce GUI does not display program names, but I've included a call to //sendChangeMessage()// to notify the GUI anyway, so I won't forget it. If and when I do add a program-name display to the GUI, it will get updated whenever the name is changed through the plugin host.
  
 ===== The preset-handling functions ===== ===== The preset-handling functions =====
  
-The plugin host can call //getCurrentProgramStateInformation()// to get the current preset as a "blob" of binary data (which it can e.g. save to a ''.fxp'' file), or call //setCurrentProgramStateInformation()// to do the reverse operation. In an early version of VanillaJuce, I simply did a binary copy of the //SynthParameters// ''struct'', but I realized that would cause problems as I changed the structure over time, so the new code uses JUCE's XML capabilities to save and restore the data in XML format:+The plugin host can call //getCurrentProgramStateInformation()// to get the current preset as a "blob" of binary data (which it can e.g. save to a ''.fxp'' file), or call //setCurrentProgramStateInformation()// to do the reverse operation. In an early version of VanillaJuce, I simply did a binary copy of the //SynthParameters// ''struct'', but I realized that would cause problems as I changed the structure over time, so the new code uses JUCE's XML capabilities to save and restore the data in XML format. (I based my code on that in [[https://github.com/2DaT/Obxd|Obxd]].)
 <code cpp> <code cpp>
 void VanillaJuceAudioProcessor::getCurrentProgramStateInformation(MemoryBlock& destData) void VanillaJuceAudioProcessor::getCurrentProgramStateInformation(MemoryBlock& destData)
Line 107: Line 120:
 } }
 </code> </code>
 +Note that //setCurrentProgramStateInformation()// also calls //sendChangeMessage()// because it changes the current preset, and so must notify the GUI.
 +
 Most of the details are in the //getXml()// and //putXml()// member functions of //SynthParameters//. The code is unremarkable, but serves to generate and parse XML structures like this (formatted for clarity): Most of the details are in the //getXml()// and //putXml()// member functions of //SynthParameters//. The code is unremarkable, but serves to generate and parse XML structures like this (formatted for clarity):
 <code xml> <code xml>
Line 162: Line 177:
 } }
 </code> </code>
 +Note that //setStateInformation()// also calls //sendChangeMessage()// because it changes all presets, //including the current one//, and so must notify the GUI.
  
-The XML structure for patch banks looks like this:+The XML structure for patch banks looks like this, where each ''<program ... />'' item is structured as above:
 <code xml> <code xml>
 <VanillaJuce currentProgram="0"> <VanillaJuce currentProgram="0">
Line 172: Line 188:
 </VanillaJuce></code> </VanillaJuce></code>
  
 +===== Rendering sound: processBlock() =====
  
 The //processBlock()// function, which actually renders audio, simply delegates to the //Synth// object: The //processBlock()// function, which actually renders audio, simply delegates to the //Synth// object:
the_plugin_processor.1504114679.txt.gz · Last modified: 2017/08/30 17:37 by shane