Skip to content

Commit

Permalink
Improve Sample restoring between sessions
Browse files Browse the repository at this point in the history
Fixes Part of Issue #3. The restored path of a sample is now saved correctly.
  • Loading branch information
passivist committed Feb 10, 2017
1 parent 8399e1c commit 8e0e37d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
Binary file not shown.
Binary file modified Builds/MacOSX/build/Debug/libGRRNLRR.a
Binary file not shown.
15 changes: 9 additions & 6 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ GrrnlrrAudioProcessorEditor::GrrnlrrAudioProcessorEditor (GrrnlrrAudioProcessor&
startThread();

setSize (500, 300);

LOG("PluginEditor constructor called");
}

GrrnlrrAudioProcessorEditor::~GrrnlrrAudioProcessorEditor()
Expand Down Expand Up @@ -177,7 +179,10 @@ void GrrnlrrAudioProcessorEditor::checkForRestoredPath()
{
String path;
path = processor.restoredPath;

if(path.isNotEmpty()){
//processor.filePath = path;

swapVariables(chosenPath, path);
processor.restoredPath = "";
}
Expand All @@ -189,6 +194,7 @@ void GrrnlrrAudioProcessorEditor::checkForPathToOpen()
swapVariables(pathToOpen, chosenPath);

if(pathToOpen.isNotEmpty()){
processor.filePath = pathToOpen;
loadAudioFile(pathToOpen);
}
}
Expand Down Expand Up @@ -224,9 +230,6 @@ void GrrnlrrAudioProcessorEditor::openButtonClicked()
String path (file.getFullPathName());
swapVariables (chosenPath, path);

processor.filePath = chosenPath;
std::cout << processor.filePath << std::endl;

notify();
}
}
Expand All @@ -239,9 +242,9 @@ void GrrnlrrAudioProcessorEditor::paint (Graphics& g)
void GrrnlrrAudioProcessorEditor::loadAudioFile(String path)
{
const File file (path);

LOG("Trying to load a file at: " << path << "\n");
if(file.exists()){
std::cout << "We have a file!" << std::endl;
LOG("We have a file at: " << path << "\n");
// we create the right kind of AudioFormatReader for our File
ScopedPointer<AudioFormatReader> reader(formatManager.createReaderFor(file));
ReferenceCountedBuffer::Ptr newBuffer = new ReferenceCountedBuffer(file.getFileName(),
Expand All @@ -257,6 +260,6 @@ void GrrnlrrAudioProcessorEditor::loadAudioFile(String path)
processor.fileBuffer = newBuffer;
}
} else {
std::cout << "Sorry but the file you are trying to load does not exist :(" << std::endl;
LOG("Sorry but the file you are trying to load does not exist :(");
}
}
9 changes: 4 additions & 5 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "PluginProcessor.h"
#include "PluginEditor.h"

#define LOG(textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON (juce::String tempDbgBuf; tempDbgBuf << textToWrite; juce::Logger::writeToLog (tempDbgBuf);)
//==============================================================================
GrrnlrrAudioProcessor::GrrnlrrAudioProcessor() : Thread("scheduling thread"),
positionParam(nullptr),
Expand Down Expand Up @@ -46,6 +44,7 @@ GrrnlrrAudioProcessor::GrrnlrrAudioProcessor() : Thread("scheduling thread"),

time = 0;
startThread();

}

GrrnlrrAudioProcessor::~GrrnlrrAudioProcessor()
Expand Down Expand Up @@ -283,7 +282,7 @@ void GrrnlrrAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// Here's an example of how you can use XML to make it easy and more robust:
LOG("Save Settings: ");
LOG("\nSave Settings: ");

// Create an outer XML element..
XmlElement xml ("GRRNLRRPLUGINSETTINGS");
Expand All @@ -301,7 +300,7 @@ void GrrnlrrAudioProcessor::getStateInformation (MemoryBlock& destData)
}

xml.setAttribute("FilePath", filePath);
LOG("\n Save Path: " << filePath);
LOG("\nSave Path: " << filePath);

// then use this helper function to stuff it into the binary blob and return it..
copyXmlToBinary (xml, destData);
Expand Down Expand Up @@ -333,7 +332,7 @@ void GrrnlrrAudioProcessor::setStateInformation (const void* data, int sizeInByt
}
}
restoredPath = xmlState->getStringAttribute("FilePath");
LOG("\n Load Path: " << filePath);
LOG("\nLoad Path: " << restoredPath);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "ReferenceCountedBuffer.h"
#include "ParameterGUIclasses.h"

#define LOG(textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON (juce::String tempDbgBuf; tempDbgBuf << textToWrite; juce::Logger::writeToLog (tempDbgBuf);)

//==============================================================================
/**
*/
Expand Down

0 comments on commit 8e0e37d

Please sign in to comment.