Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to toggle speakers orientation option for speakerview (in SpatGRIS View Menu) #447

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Resources/default_preset/default_preset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Master_Interpolation="0.1" Show_Numbers="0" Show_Speakers="1"
Show_Triplets="0" Use_Alpha="0" Show_Speaker_Level="0"
Show_Sphere="0" CamAngleX="89.66667938232422" CamAngleY="20.66667175292969"
CamDistance="22.00703048706055">
CamDistance="22.00703048706055" Keep_Speakers_Origin_Orientated="1">
<Input Index="1" R="1.0" G="0.0" B="0.0" DirectOut="0"/>
<Input Index="2" R="1.0" G="0.09411764889955521" B="0.0" DirectOut="0"/>
<Input Index="3" R="0.0117647061124444" G="0.03529411926865578" B="1.0"
Expand Down Expand Up @@ -39,4 +39,4 @@
DirectOut="17"/>
<Input Index="18" R="0.4274509847164154" G="0.003921568859368563" B="0.003921568859368563"
DirectOut="18"/>
</ServerGRIS_Preset>
</ServerGRIS_Preset>
1 change: 1 addition & 0 deletions Source/sg_CommandId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum CommandId {
showSourceActivityId,
showSpeakerActivityId,
showSphereId,
keepSpeakersOriginOrientatedId,

colorizeInputsId,
resetInputPosId,
Expand Down
5 changes: 4 additions & 1 deletion Source/sg_LogicStrucs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ juce::String const ViewSettings::XmlTags::SHOW_SPEAKER_TRIPLETS = "SHOW_SPEAKER_
juce::String const ViewSettings::XmlTags::SHOW_SPEAKER_LEVELS = "SHOW_SPEAKER_LEVELS";
juce::String const ViewSettings::XmlTags::SHOW_SPHERE_OR_CUBE = "SHOW_SPHERE_OR_CUBE";
juce::String const ViewSettings::XmlTags::SHOW_SOURCE_ACTIVITY = "SHOW_SOURCE_ACTIVITY";
juce::String const ViewSettings::XmlTags::KEEP_SPEAKERS_ORIGIN_ORIENTED = "KEEP_SPEAKERS_ORIGIN_ORIENTED";

juce::String const ProjectData::XmlTags::MAIN_TAG = "SPAT_GRIS_PROJECT_DATA";
juce::String const ProjectData::XmlTags::VERSION = "VERSION";
Expand Down Expand Up @@ -565,6 +566,7 @@ std::unique_ptr<juce::XmlElement> ViewSettings::toXml() const
result->setAttribute(XmlTags::SHOW_SPEAKER_LEVELS, showSpeakerLevels);
result->setAttribute(XmlTags::SHOW_SPHERE_OR_CUBE, showSphereOrCube);
result->setAttribute(XmlTags::SHOW_SOURCE_ACTIVITY, showSourceActivity);
result->setAttribute(XmlTags::KEEP_SPEAKERS_ORIGIN_ORIENTED, keepSpeakersOriginOriented);

return result;
}
Expand All @@ -576,7 +578,7 @@ tl::optional<ViewSettings> ViewSettings::fromXml(juce::XmlElement const & xml)
XmlTags::SHOW_SPEAKERS, XmlTags::SHOW_SOURCE_NUMBERS,
XmlTags::SHOW_SPEAKER_NUMBERS, XmlTags::SHOW_SPEAKER_TRIPLETS,
XmlTags::SHOW_SPEAKER_LEVELS, XmlTags::SHOW_SPHERE_OR_CUBE,
XmlTags::SHOW_SOURCE_ACTIVITY };
XmlTags::SHOW_SOURCE_ACTIVITY, XmlTags::KEEP_SPEAKERS_ORIGIN_ORIENTED};

if (xml.getTagName() != XmlTags::MAIN_TAG
|| !std::all_of(requiredTags.begin(), requiredTags.end(), [&](juce::String const & tag) {
Expand All @@ -595,6 +597,7 @@ tl::optional<ViewSettings> ViewSettings::fromXml(juce::XmlElement const & xml)
result.showSpeakerLevels = xml.getBoolAttribute(XmlTags::SHOW_SPEAKER_LEVELS);
result.showSphereOrCube = xml.getBoolAttribute(XmlTags::SHOW_SPHERE_OR_CUBE);
result.showSourceActivity = xml.getBoolAttribute(XmlTags::SHOW_SOURCE_ACTIVITY);
result.keepSpeakersOriginOriented = xml.getBoolAttribute(XmlTags::KEEP_SPEAKERS_ORIGIN_ORIENTED);

return result;
}
Expand Down
2 changes: 2 additions & 0 deletions Source/sg_LogicStrucs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct ViewSettings {
bool showSpeakerLevels{ false };
bool showSphereOrCube{ false };
bool showSourceActivity{ false };
bool keepSpeakersOriginOriented{ true };
//==============================================================================
[[nodiscard]] std::unique_ptr<juce::XmlElement> toXml() const;
[[nodiscard]] static tl::optional<ViewSettings> fromXml(juce::XmlElement const & xml);
Expand All @@ -92,6 +93,7 @@ struct ViewSettings {
static juce::String const SHOW_SPEAKER_LEVELS;
static juce::String const SHOW_SPHERE_OR_CUBE;
static juce::String const SHOW_SOURCE_ACTIVITY;
static juce::String const KEEP_SPEAKERS_ORIGIN_ORIENTED;
};
};

Expand Down
25 changes: 23 additions & 2 deletions Source/sg_MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,18 @@ void MainContentComponent::handleOpenManualFR()
juce::Process::openDocument("file:" + MANUAL_FILE_FR.getFullPathName(), juce::String());
}
}
//==============================================================================
void MainContentComponent::handleShowSpeakerOrientation()
{
JUCE_ASSERT_MESSAGE_THREAD;
{
juce::ScopedWriteLock const lock{ mLock };

auto & var{ mData.appData.viewSettings.keepSpeakersOriginOriented };
var = !var;
}
refreshViewportConfig();
}

//==============================================================================
void MainContentComponent::masterGainChanged(dbfs_t const gain)
Expand Down Expand Up @@ -1165,7 +1177,7 @@ void MainContentComponent::getAllCommands(juce::Array<juce::CommandID> & command
{
JUCE_ASSERT_MESSAGE_THREAD;

constexpr std::array<CommandId, 30> ids{ CommandId::newProjectId,
constexpr std::array<CommandId, 31> ids{ CommandId::newProjectId,
CommandId::openProjectId,
CommandId::saveProjectId,
CommandId::saveProjectAsId,
Expand Down Expand Up @@ -1194,7 +1206,8 @@ void MainContentComponent::getAllCommands(juce::Array<juce::CommandID> & command
CommandId::aboutId,
CommandId::openManualENId,
CommandId::openManualFRId,
CommandId::playerPlayStopId };
CommandId::playerPlayStopId,
CommandId::keepSpeakersOriginOrientatedId};

commands.addArray(ids.data(), narrow<int>(ids.size()));

Expand Down Expand Up @@ -1363,6 +1376,10 @@ void MainContentComponent::getCommandInfo(juce::CommandID const commandId, juce:
result.setInfo("Play Stop", "Play or Stop Player Playback", generalCategory, 0);
result.addDefaultKeypress(juce::KeyPress::spaceKey, juce::ModifierKeys::noModifiers);
return;
case CommandId::keepSpeakersOriginOrientatedId:
result.setInfo("Keep Speakers Orientated Towards Origin", "Toggle the Speakers Orientation", generalCategory, 0);
result.setTicked(mData.appData.viewSettings.keepSpeakersOriginOriented);
return;
}

// probably a template
Expand Down Expand Up @@ -1469,6 +1486,9 @@ bool MainContentComponent::perform(InvocationInfo const & info)
case CommandId::playerPlayStopId:
handlePlayerPlayStop();
break;
case CommandId::keepSpeakersOriginOrientatedId:
handleShowSpeakerOrientation();
break;
default:
// open a template
auto const templateInfo{ commandIdToTemplate(info.commandID) };
Expand Down Expand Up @@ -1596,6 +1616,7 @@ juce::PopupMenu MainContentComponent::getMenuForIndex(int /*menuIndex*/, const j
menu.addCommandItem(commandManager, CommandId::showSourceNumbersId);
menu.addCommandItem(commandManager, CommandId::showSpeakerNumbersId);
menu.addCommandItem(commandManager, CommandId::showSpeakersId);
menu.addCommandItem(commandManager, CommandId::keepSpeakersOriginOrientatedId);
if (mAudioProcessor->getSpatAlgorithm()->hasTriplets()) {
menu.addCommandItem(commandManager, CommandId::showTripletsId);
} else {
Expand Down
1 change: 1 addition & 0 deletions Source/sg_MainComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ class MainContentComponent final
void handleSaveSpeakerSetup();
void handleSaveSpeakerSetupAs();
void handleShowOscMonitorWindow();
void handleShowSpeakerOrientation();

void refreshSourceSlices();
void refreshSpeakerSlices();
Expand Down
1 change: 1 addition & 0 deletions Source/sg_SpeakerViewComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ void SpeakerViewComponent::prepareSGInfos()
mJsonSGInfos->setProperty("showSourceActivity", viewSettings.showSourceActivity);
mJsonSGInfos->setProperty("showSpeakerLevel", viewSettings.showSpeakerLevels);
mJsonSGInfos->setProperty("showSphereOrCube", viewSettings.showSphereOrCube);
mJsonSGInfos->setProperty("keepSpeakersOriginOriented", viewSettings.keepSpeakersOriginOriented);

juce::Array<juce::var> triplets;
for (auto const & triplet : mData.coldData.triplets) {
Expand Down