MIDI learn menu
This commit is contained in:
parent
f52aedeb7d
commit
b5c671a8f9
5 changed files with 103 additions and 15 deletions
0
Source/Components/PresetBar.cpp
Executable file → Normal file
0
Source/Components/PresetBar.cpp
Executable file → Normal file
|
@ -435,6 +435,7 @@ void ObxdAudioProcessorEditor::createMenu ()
|
|||
PopupMenu skinMenu;
|
||||
PopupMenu fileMenu;
|
||||
PopupMenu viewMenu;
|
||||
PopupMenu midiMenu;
|
||||
skins = processor.getSkinFiles();
|
||||
banks = processor.getBankFiles();
|
||||
{
|
||||
|
@ -534,9 +535,57 @@ void ObxdAudioProcessorEditor::createMenu ()
|
|||
}
|
||||
viewMenu.addItem(progStart + 1000, "Preset Bar", true, processor.showPresetBar);
|
||||
menu->addSubMenu ("View", viewMenu);
|
||||
menuMidiNum = progStart +2000;
|
||||
createMidi(menuMidiNum, midiMenu);
|
||||
menu->addSubMenu ("MIDI", midiMenu);
|
||||
popupMenus.add (menu);
|
||||
}
|
||||
|
||||
void ObxdAudioProcessorEditor::createMidi(int menuNo, PopupMenu &menuMidi) {
|
||||
File midi_dir = processor.getMidiFolder();
|
||||
File default_file = midi_dir.getChildFile("Default.xml");
|
||||
if(default_file.exists()){
|
||||
if (processor.currentMidiPath != default_file.getFullPathName()){
|
||||
menuMidi.addItem(menuNo++, default_file.getFileNameWithoutExtension(), true, false);
|
||||
} else {
|
||||
menuMidi.addItem(menuNo++, default_file.getFileNameWithoutExtension(), true, true);
|
||||
}
|
||||
midiFiles.add(default_file.getFullPathName());
|
||||
}
|
||||
|
||||
File custom_file = midi_dir.getChildFile("Custom.xml");
|
||||
|
||||
if(custom_file.exists()){
|
||||
if (processor.currentMidiPath != custom_file.getFullPathName()){
|
||||
menuMidi.addItem(menuNo++, custom_file.getFileNameWithoutExtension(), true, false);
|
||||
} else {
|
||||
menuMidi.addItem(menuNo++, custom_file.getFileNameWithoutExtension(), true, true);
|
||||
}
|
||||
midiFiles.add(custom_file.getFullPathName());
|
||||
}
|
||||
|
||||
DirectoryIterator iter (midi_dir, true, "*.xml");
|
||||
StringArray list;
|
||||
while (iter.next())
|
||||
{
|
||||
list.add(iter.getFile().getFullPathName());
|
||||
}
|
||||
|
||||
list.sort(true);
|
||||
|
||||
for (int i =0; i < list.size() ; i ++){
|
||||
File f (list[i]);
|
||||
if (f.getFileNameWithoutExtension() != "Default" && f.getFileNameWithoutExtension() != "Custom" && f.getFileNameWithoutExtension() != "Config") {
|
||||
if (processor.currentMidiPath != f.getFullPathName()){
|
||||
menuMidi.addItem(menuNo++, f.getFileNameWithoutExtension(), true, false);
|
||||
} else {
|
||||
menuMidi.addItem(menuNo++, f.getFileNameWithoutExtension(), true, true);
|
||||
}
|
||||
midiFiles.add(f.getFullPathName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObxdAudioProcessorEditor::resultFromMenu (const Point<int> pos)
|
||||
{
|
||||
int result = popupMenus[0]->showAt (Rectangle<int> (pos.getX(), pos.getY(), 1, 1));
|
||||
|
@ -579,6 +628,19 @@ void ObxdAudioProcessorEditor::resultFromMenu (const Point<int> pos)
|
|||
createMenu();
|
||||
updatePresetBar();
|
||||
}
|
||||
else if (result >= menuMidiNum){
|
||||
unsigned int selected_idx = result - menuMidiNum;
|
||||
if (selected_idx >= 0 && selected_idx < midiFiles.size()){
|
||||
File f(midiFiles[selected_idx]);
|
||||
if (f.exists()) {
|
||||
processor.currentMidiPath = midiFiles[selected_idx];
|
||||
processor.bindings.loadFile(f);
|
||||
processor.updateConfig();
|
||||
|
||||
createMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObxdAudioProcessorEditor::updatePresetBar(bool resize){
|
||||
|
|
|
@ -167,6 +167,7 @@ private:
|
|||
ButtonList* addList(int x, int y, int w, int h, ObxdAudioProcessor& filter, int parameter, String name, Image img);
|
||||
void addMenuButton (int x, int y, int d, const Image&);
|
||||
void createMenu ();
|
||||
void createMidi(int, PopupMenu &);
|
||||
void resultFromMenu (const Point<int>);
|
||||
void clean();
|
||||
|
||||
|
@ -275,6 +276,8 @@ private:
|
|||
ApplicationCommandManager commandManager;
|
||||
int countTimer =0;
|
||||
bool needNotifytoHost = false;
|
||||
Array<String> midiFiles;
|
||||
int menuMidiNum;
|
||||
};
|
||||
|
||||
#endif // PLUGINEDITOR_H_INCLUDED
|
||||
|
|
|
@ -274,8 +274,7 @@ inline void ObxdAudioProcessor::processMidiPerSample (MidiBuffer::Iterator* iter
|
|||
midiControlledParamSet = true;
|
||||
//bindings[lastMovedController] = lastUsedParameter;
|
||||
bindings.updateCC(lastUsedParameter, lastMovedController);
|
||||
File midi_file = getDocumentFolder().getChildFile("Midi")
|
||||
.getChildFile("Custom.xml");
|
||||
File midi_file = getMidiFolder().getChildFile("Custom.xml");
|
||||
bindings.saveFile(midi_file);
|
||||
currentMidiPath = midi_file.getFullPathName();
|
||||
|
||||
|
@ -791,6 +790,12 @@ File ObxdAudioProcessor::getBanksFolder() const
|
|||
return getDocumentFolder().getChildFile("Banks");
|
||||
}
|
||||
|
||||
File ObxdAudioProcessor::getMidiFolder() const
|
||||
{
|
||||
return getDocumentFolder().getChildFile("Midi");
|
||||
}
|
||||
|
||||
|
||||
File ObxdAudioProcessor::getPresetsFolder() const
|
||||
{
|
||||
return getDocumentFolder().getChildFile("Presets");
|
||||
|
@ -1201,22 +1206,37 @@ AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
|||
|
||||
void ObxdAudioProcessor::initMidi(){
|
||||
//Documents > Obxd > MIDI > Default.xml
|
||||
File default_file = getDocumentFolder().getChildFile("Midi")
|
||||
.getChildFile("Default.xml");
|
||||
File default_file = getMidiFolder().getChildFile("Default.xml");
|
||||
if (!default_file.exists()){
|
||||
bindings.saveFile(default_file);
|
||||
}
|
||||
|
||||
File midi_custom_file = getDocumentFolder().getChildFile("Midi")
|
||||
.getChildFile("Custom.xml");
|
||||
File midi_config_file = getMidiFolder().getChildFile("Config.xml");
|
||||
XmlDocument xmlDoc (midi_config_file);
|
||||
std::unique_ptr<XmlElement> ele_file = xmlDoc.getDocumentElementIfTagMatches("File");
|
||||
|
||||
if (midi_custom_file.exists()) {
|
||||
if (bindings.loadFile(midi_custom_file)){
|
||||
currentMidiPath = midi_custom_file.getFullPathName();
|
||||
if (ele_file) {
|
||||
String file_name = ele_file->getStringAttribute("name");
|
||||
// Midi cc loading
|
||||
File midi_file = getMidiFolder().getChildFile(file_name);
|
||||
if (bindings.loadFile(midi_file)){
|
||||
currentMidiPath = midi_file.getFullPathName();
|
||||
} else {
|
||||
if (bindings.loadFile(default_file)){
|
||||
currentMidiPath = default_file.getFullPathName();
|
||||
File midi_file = getMidiFolder().getChildFile("Default.xml");
|
||||
if (bindings.loadFile(midi_file)){
|
||||
currentMidiPath = midi_file.getFullPathName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObxdAudioProcessor::updateConfig(){
|
||||
File midi_config_file = getMidiFolder().getChildFile("Config.xml");
|
||||
XmlDocument xmlDoc (midi_config_file);
|
||||
std::unique_ptr<XmlElement> ele_file = xmlDoc.getDocumentElementIfTagMatches("File");
|
||||
if (ele_file) {
|
||||
File f(currentMidiPath);
|
||||
ele_file->setAttribute("name", f.getFileName());
|
||||
ele_file->writeTo(midi_config_file.getFullPathName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public:
|
|||
void newPreset(const String &name);
|
||||
void deletePreset();
|
||||
|
||||
bool loadFromFXBFile(const File& fxbFile, bool changeProgram=true);
|
||||
bool loadFromFXBFile(const File& fxbFile);
|
||||
bool saveFXBFile(const File& fxbFile);
|
||||
bool saveFXPFile(const File& fxpFile);
|
||||
bool saveBank(const File& fxbFile);
|
||||
|
@ -191,6 +191,7 @@ public:
|
|||
File getSkinFolder() const;
|
||||
File getPresetsFolder() const;
|
||||
File getBanksFolder() const;
|
||||
File getMidiFolder() const;
|
||||
|
||||
File getCurrentSkinFolder() const;
|
||||
void setCurrentSkinFolder(const String& folderName);
|
||||
|
@ -219,7 +220,7 @@ private:
|
|||
|
||||
MidiMessage* nextMidi;
|
||||
MidiMessage* midiMsg;
|
||||
MidiMap bindings;
|
||||
|
||||
bool midiControlledParamSet;
|
||||
|
||||
bool hasMidiMessage;
|
||||
|
@ -238,8 +239,10 @@ public:
|
|||
String currentPreset;
|
||||
File currentPresetFile;
|
||||
void savePreset();
|
||||
|
||||
MidiMap bindings;
|
||||
bool showPresetBar = false;
|
||||
|
||||
void updateConfig();
|
||||
private:
|
||||
Array<File> bankFiles;
|
||||
Array<File> skinFiles;
|
||||
|
|
Loading…
Reference in a new issue