Skip to content

Commit

Permalink
Fix iOS build (#92)
Browse files Browse the repository at this point in the history
* Fix iOS project

* Update iPlug2 submodule

* Use completion handlers for dialogs

* Disable portrait mode on iOS

* Implement OnHostRequestingSupportedViewConfiguration() for AUv3 size

* Adjust scale factor on iOS so that the load buttons are accesible

in Garageband. Also set the view background black
  • Loading branch information
olilarkin authored Mar 4, 2023
1 parent e1410f3 commit 630bbf5
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 284 deletions.
152 changes: 81 additions & 71 deletions NeuralAmpModeler/NeuralAmpModeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo &info)
this->mNoiseGateTrigger.AddListener(&this->mNoiseGateGain);

mMakeGraphicsFunc = [&]() {
return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS,
GetScaleForScreen(PLUG_WIDTH, PLUG_HEIGHT));

#ifdef OS_IOS
auto scaleFactor = GetScaleForScreen(PLUG_WIDTH, PLUG_HEIGHT) * 0.85f;
#else
auto scaleFactor = 1.0f;
#endif

return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS, scaleFactor);
};

mLayoutFunc = [&](IGraphics *pGraphics) {
Expand Down Expand Up @@ -204,82 +210,86 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo &info)

// Model loader button
auto loadNAM = [&, pGraphics](IControl *pCaller) {
WDL_String filename;
WDL_String path(this->mNAMPath.remove_filepart());
pGraphics->PromptForFile(filename, path);
if (filename.GetLength()) {
// Sets mNAMPath and mStagedNAM
const std::string msg = this->_GetNAM(filename);
// TODO error messages like the IR loader.
if (msg.size()) {
std::stringstream ss;
ss << "Failed to load NAM model. Message:\n\n"
<< msg << "\n\n"
<< "If the model is an old \"directory-style\" model, it can be "
"converted using the utility at "
"https://github.com/sdatkinson/nam-model-utility";
pGraphics->ShowMessageBox(ss.str().c_str(), "Failed to load model!",
kMB_OK);
WDL_String initFileName;
WDL_String initPath(this->mNAMPath.remove_filepart());
pGraphics->PromptForFile(initFileName, initPath, EFileAction::Open, "nam",
[&](const WDL_String& fileName, const WDL_String& path){
if (fileName.GetLength()) {
// Sets mNAMPath and mStagedNAM
const std::string msg = this->_GetNAM(fileName);
// TODO error messages like the IR loader.
if (msg.size()) {
std::stringstream ss;
ss << "Failed to load NAM model. Message:\n\n"
<< msg << "\n\n"
<< "If the model is an old \"directory-style\" model, it can be "
"converted using the utility at "
"https://github.com/sdatkinson/nam-model-utility";
pGraphics->ShowMessageBox(ss.str().c_str(), "Failed to load model!",
kMB_OK);
}
}
}
});
};
// IR loader button
auto loadIR = [&, pGraphics](IControl *pCaller) {
WDL_String fileName;
WDL_String path(this->mIRPath.remove_filepart());
pGraphics->PromptForFile(fileName, path);
if (fileName.GetLength()) {
this->mIRPath = fileName;
const dsp::wav::LoadReturnCode retCode = this->_GetIR(fileName);
if (retCode != dsp::wav::LoadReturnCode::SUCCESS) {
std::stringstream message;
message << "Failed to load IR file " << fileName.Get() << ":\n";
switch (retCode) {
case (dsp::wav::LoadReturnCode::ERROR_OPENING):
message
WDL_String initFileName;
WDL_String initPath(this->mIRPath.remove_filepart());
pGraphics->PromptForFile(initFileName, initPath, EFileAction::Open, "wav",
[&](const WDL_String& fileName, const WDL_String& path){
if (fileName.GetLength()) {
this->mIRPath = fileName;
const dsp::wav::LoadReturnCode retCode = this->_GetIR(fileName);
if (retCode != dsp::wav::LoadReturnCode::SUCCESS) {
std::stringstream message;
message << "Failed to load IR file " << fileName.Get() << ":\n";
switch (retCode) {
case (dsp::wav::LoadReturnCode::ERROR_OPENING):
message
<< "Failed to open file (is it being used by another program?)";
break;
case (dsp::wav::LoadReturnCode::ERROR_NOT_RIFF):
message << "File is not a WAV file.";
break;
case (dsp::wav::LoadReturnCode::ERROR_NOT_WAVE):
message << "File is not a WAV file.";
break;
case (dsp::wav::LoadReturnCode::ERROR_MISSING_FMT):
message << "File is missing expected format chunk.";
break;
case (dsp::wav::LoadReturnCode::ERROR_INVALID_FILE):
message << "WAV file contents are invalid.";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_IEEE_FLOAT):
message << "Unsupported file format \"IEEE float\"";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_ALAW):
message << "Unsupported file format \"A-law\"";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_MULAW):
message << "Unsupported file format \"mu-law\"";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_EXTENSIBLE):
message << "Unsupported file format \"extensible\"";
break;
case (dsp::wav::LoadReturnCode::ERROR_NOT_MONO):
message << "File is not mono.";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_BITS_PER_SAMPLE):
message << "Unsupported bits per sample";
break;
case (dsp::wav::LoadReturnCode::ERROR_OTHER):
message << "???";
break;
default:
message << "???";
break;
break;
case (dsp::wav::LoadReturnCode::ERROR_NOT_RIFF):
message << "File is not a WAV file.";
break;
case (dsp::wav::LoadReturnCode::ERROR_NOT_WAVE):
message << "File is not a WAV file.";
break;
case (dsp::wav::LoadReturnCode::ERROR_MISSING_FMT):
message << "File is missing expected format chunk.";
break;
case (dsp::wav::LoadReturnCode::ERROR_INVALID_FILE):
message << "WAV file contents are invalid.";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_IEEE_FLOAT):
message << "Unsupported file format \"IEEE float\"";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_ALAW):
message << "Unsupported file format \"A-law\"";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_MULAW):
message << "Unsupported file format \"mu-law\"";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_FORMAT_EXTENSIBLE):
message << "Unsupported file format \"extensible\"";
break;
case (dsp::wav::LoadReturnCode::ERROR_NOT_MONO):
message << "File is not mono.";
break;
case (dsp::wav::LoadReturnCode::ERROR_UNSUPPORTED_BITS_PER_SAMPLE):
message << "Unsupported bits per sample";
break;
case (dsp::wav::LoadReturnCode::ERROR_OTHER):
message << "???";
break;
default:
message << "???";
break;
}
pGraphics->ShowMessageBox(message.str().c_str(), "Failed to load IR!",
kMB_OK);
}
pGraphics->ShowMessageBox(message.str().c_str(), "Failed to load IR!",
kMB_OK);
}
}
});
};
// Model-clearing function
auto ClearNAM = [&, pGraphics](IControl *pCaller) {
Expand Down
1 change: 1 addition & 0 deletions NeuralAmpModeler/NeuralAmpModeler.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class NeuralAmpModeler final : public iplug::Plugin {
bool SerializeState(iplug::IByteChunk &chunk) const override;
int UnserializeState(const iplug::IByteChunk &chunk, int startPos) override;
void OnUIOpen() override;
bool OnHostRequestingSupportedViewConfiguration(int width, int height) override { return true; }

private:
// Allocates mInputPointers and mOutputPointers
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 630bbf5

Please sign in to comment.