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 skinMenu;
|
||||||
PopupMenu fileMenu;
|
PopupMenu fileMenu;
|
||||||
PopupMenu viewMenu;
|
PopupMenu viewMenu;
|
||||||
|
PopupMenu midiMenu;
|
||||||
skins = processor.getSkinFiles();
|
skins = processor.getSkinFiles();
|
||||||
banks = processor.getBankFiles();
|
banks = processor.getBankFiles();
|
||||||
{
|
{
|
||||||
|
@ -534,9 +535,57 @@ void ObxdAudioProcessorEditor::createMenu ()
|
||||||
}
|
}
|
||||||
viewMenu.addItem(progStart + 1000, "Preset Bar", true, processor.showPresetBar);
|
viewMenu.addItem(progStart + 1000, "Preset Bar", true, processor.showPresetBar);
|
||||||
menu->addSubMenu ("View", viewMenu);
|
menu->addSubMenu ("View", viewMenu);
|
||||||
|
menuMidiNum = progStart +2000;
|
||||||
|
createMidi(menuMidiNum, midiMenu);
|
||||||
|
menu->addSubMenu ("MIDI", midiMenu);
|
||||||
popupMenus.add (menu);
|
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)
|
void ObxdAudioProcessorEditor::resultFromMenu (const Point<int> pos)
|
||||||
{
|
{
|
||||||
int result = popupMenus[0]->showAt (Rectangle<int> (pos.getX(), pos.getY(), 1, 1));
|
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();
|
createMenu();
|
||||||
updatePresetBar();
|
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){
|
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);
|
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 addMenuButton (int x, int y, int d, const Image&);
|
||||||
void createMenu ();
|
void createMenu ();
|
||||||
|
void createMidi(int, PopupMenu &);
|
||||||
void resultFromMenu (const Point<int>);
|
void resultFromMenu (const Point<int>);
|
||||||
void clean();
|
void clean();
|
||||||
|
|
||||||
|
@ -275,6 +276,8 @@ private:
|
||||||
ApplicationCommandManager commandManager;
|
ApplicationCommandManager commandManager;
|
||||||
int countTimer =0;
|
int countTimer =0;
|
||||||
bool needNotifytoHost = false;
|
bool needNotifytoHost = false;
|
||||||
|
Array<String> midiFiles;
|
||||||
|
int menuMidiNum;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLUGINEDITOR_H_INCLUDED
|
#endif // PLUGINEDITOR_H_INCLUDED
|
||||||
|
|
|
@ -274,8 +274,7 @@ inline void ObxdAudioProcessor::processMidiPerSample (MidiBuffer::Iterator* iter
|
||||||
midiControlledParamSet = true;
|
midiControlledParamSet = true;
|
||||||
//bindings[lastMovedController] = lastUsedParameter;
|
//bindings[lastMovedController] = lastUsedParameter;
|
||||||
bindings.updateCC(lastUsedParameter, lastMovedController);
|
bindings.updateCC(lastUsedParameter, lastMovedController);
|
||||||
File midi_file = getDocumentFolder().getChildFile("Midi")
|
File midi_file = getMidiFolder().getChildFile("Custom.xml");
|
||||||
.getChildFile("Custom.xml");
|
|
||||||
bindings.saveFile(midi_file);
|
bindings.saveFile(midi_file);
|
||||||
currentMidiPath = midi_file.getFullPathName();
|
currentMidiPath = midi_file.getFullPathName();
|
||||||
|
|
||||||
|
@ -791,6 +790,12 @@ File ObxdAudioProcessor::getBanksFolder() const
|
||||||
return getDocumentFolder().getChildFile("Banks");
|
return getDocumentFolder().getChildFile("Banks");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File ObxdAudioProcessor::getMidiFolder() const
|
||||||
|
{
|
||||||
|
return getDocumentFolder().getChildFile("Midi");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
File ObxdAudioProcessor::getPresetsFolder() const
|
File ObxdAudioProcessor::getPresetsFolder() const
|
||||||
{
|
{
|
||||||
return getDocumentFolder().getChildFile("Presets");
|
return getDocumentFolder().getChildFile("Presets");
|
||||||
|
@ -1201,22 +1206,37 @@ AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
||||||
|
|
||||||
void ObxdAudioProcessor::initMidi(){
|
void ObxdAudioProcessor::initMidi(){
|
||||||
//Documents > Obxd > MIDI > Default.xml
|
//Documents > Obxd > MIDI > Default.xml
|
||||||
File default_file = getDocumentFolder().getChildFile("Midi")
|
File default_file = getMidiFolder().getChildFile("Default.xml");
|
||||||
.getChildFile("Default.xml");
|
|
||||||
if (!default_file.exists()){
|
if (!default_file.exists()){
|
||||||
bindings.saveFile(default_file);
|
bindings.saveFile(default_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
File midi_custom_file = getDocumentFolder().getChildFile("Midi")
|
File midi_config_file = getMidiFolder().getChildFile("Config.xml");
|
||||||
.getChildFile("Custom.xml");
|
XmlDocument xmlDoc (midi_config_file);
|
||||||
|
std::unique_ptr<XmlElement> ele_file = xmlDoc.getDocumentElementIfTagMatches("File");
|
||||||
|
|
||||||
if (midi_custom_file.exists()) {
|
if (ele_file) {
|
||||||
if (bindings.loadFile(midi_custom_file)){
|
String file_name = ele_file->getStringAttribute("name");
|
||||||
currentMidiPath = midi_custom_file.getFullPathName();
|
// Midi cc loading
|
||||||
|
File midi_file = getMidiFolder().getChildFile(file_name);
|
||||||
|
if (bindings.loadFile(midi_file)){
|
||||||
|
currentMidiPath = midi_file.getFullPathName();
|
||||||
} else {
|
} else {
|
||||||
if (bindings.loadFile(default_file)){
|
File midi_file = getMidiFolder().getChildFile("Default.xml");
|
||||||
currentMidiPath = default_file.getFullPathName();
|
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 newPreset(const String &name);
|
||||||
void deletePreset();
|
void deletePreset();
|
||||||
|
|
||||||
bool loadFromFXBFile(const File& fxbFile, bool changeProgram=true);
|
bool loadFromFXBFile(const File& fxbFile);
|
||||||
bool saveFXBFile(const File& fxbFile);
|
bool saveFXBFile(const File& fxbFile);
|
||||||
bool saveFXPFile(const File& fxpFile);
|
bool saveFXPFile(const File& fxpFile);
|
||||||
bool saveBank(const File& fxbFile);
|
bool saveBank(const File& fxbFile);
|
||||||
|
@ -191,6 +191,7 @@ public:
|
||||||
File getSkinFolder() const;
|
File getSkinFolder() const;
|
||||||
File getPresetsFolder() const;
|
File getPresetsFolder() const;
|
||||||
File getBanksFolder() const;
|
File getBanksFolder() const;
|
||||||
|
File getMidiFolder() const;
|
||||||
|
|
||||||
File getCurrentSkinFolder() const;
|
File getCurrentSkinFolder() const;
|
||||||
void setCurrentSkinFolder(const String& folderName);
|
void setCurrentSkinFolder(const String& folderName);
|
||||||
|
@ -219,7 +220,7 @@ private:
|
||||||
|
|
||||||
MidiMessage* nextMidi;
|
MidiMessage* nextMidi;
|
||||||
MidiMessage* midiMsg;
|
MidiMessage* midiMsg;
|
||||||
MidiMap bindings;
|
|
||||||
bool midiControlledParamSet;
|
bool midiControlledParamSet;
|
||||||
|
|
||||||
bool hasMidiMessage;
|
bool hasMidiMessage;
|
||||||
|
@ -238,8 +239,10 @@ public:
|
||||||
String currentPreset;
|
String currentPreset;
|
||||||
File currentPresetFile;
|
File currentPresetFile;
|
||||||
void savePreset();
|
void savePreset();
|
||||||
|
MidiMap bindings;
|
||||||
bool showPresetBar = false;
|
bool showPresetBar = false;
|
||||||
|
|
||||||
|
void updateConfig();
|
||||||
private:
|
private:
|
||||||
Array<File> bankFiles;
|
Array<File> bankFiles;
|
||||||
Array<File> skinFiles;
|
Array<File> skinFiles;
|
||||||
|
|
Loading…
Reference in a new issue