Skip to content

Commit

Permalink
attempts to allow variables/states to integer based inputs for actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
kylergib committed Aug 27, 2023
1 parent 426fdb9 commit 0131146
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 24 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def mainClassSimpleName = 'WaveLinkPlugin'
def mainClassPackage = 'com.kylergib.wavelinktp'
group mainClassPackage
def versionMajor = 1
def versionMinor = 1
def versionPatch = 3
def versionMinor = 2
def versionPatch = 0
version versionMajor + '.' + versionMinor + '.' + versionPatch
def versionCode = versionMajor * 1000 + versionMinor * 100 + versionPatch

Expand Down
114 changes: 92 additions & 22 deletions src/main/java/com/kylergib/wavelinktp/WaveLinkPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,22 @@ private void selectMonitorMixOutput(@Data(stateId = "outputList") String[] choic
* Action to set input volume to a specific integer
*
*/
@Action(description = "Set output volume", format = "Set output volume of: {$outputMixerId$} to {$volumeValue$}",
@Action(description = "Set output volume", format = "Set output volume of: {$outputMixerId$} to {$volumeValueString$}",
categoryId = "WaveLinkOutputs", name="Set Output Volume")
private void actionSetOutputVolume(@Data(valueChoices = {"Local", "Stream", "Both"}) String[] outputMixerId, @Data(minValue = 0, maxValue = 100) Integer volumeValue) {
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetInputVolume received: " + outputMixerId[0] + " - " + volumeValue);
private void actionSetOutputVolume(@Data(valueChoices = {"Local", "Stream", "Both"}) String[] outputMixerId, @Data() String volumeValueString) {
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetInputVolume received: " + outputMixerId[0] + " - " + volumeValueString);
Integer volumeValue = null;
try {
volumeValue = Integer.parseInt(volumeValueString);
} catch (NumberFormatException e) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetOutputVolume value could not be converted to number");
return;
}
if (volumeValue < 0 || volumeValue > 100) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetOutputVolume value has to be between 0 and 100. It was " + volumeValue);
return;
}


if (outputMixerId[0].equals("Local") || outputMixerId[0].equals("Both")) {
WaveLinkActions.setOutputConfig(Status.localPackageName,"Output Level",volumeValue);
Expand Down Expand Up @@ -417,26 +429,40 @@ private void actionSetInputFilterActive(@Data(stateId = "inputList") String[] c
/**
* Action to set input volume to a specific integer
*
* @param integerValue Integer
* @param integerValueString Integer
* @param choices list of strings
* @param mixerId list of strings
*/
@Action(description = "Set input volume", format = "Set input volume of: {$choices$} to {$integerValue$} on mixer: {$mixerId$}",
@Action(description = "Set input volume", format = "Set input volume of: {$choices$} to {$integerValueString$} on mixer: {$mixerId$}",
categoryId = "WaveLinkInputs", name="Set Input Volume")
private void actionSetInputVolume(@Data(stateId = "inputList") String[] choices, @Data(minValue = 0, maxValue = 100) Integer integerValue,
private void actionSetInputVolume(@Data(stateId = "inputList") String[] choices, @Data() String integerValueString,
@Data(valueChoices = {"Local","Stream", "Both"}) String[] mixerId) {
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetInputVolume received: " + integerValue + " - " + choices[0] + " - " + mixerId[0]);
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetInputVolume received: " + integerValueString + " - " + choices[0] + " - " + mixerId[0]);
Integer integerValue = null;
try {
integerValue = Integer.parseInt(integerValueString);
} catch (NumberFormatException e) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetInputVolume value could not be converted to number");
return;
}
if (integerValue < 0 || integerValue > 100) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetInputVolume value has to be between 0 and 100. It was " + integerValue);
return;
}


//sorts through all inputs
int finalIntegerValue = integerValue;
Status.allInputs.stream().filter(input -> isInput(input, choices[0])).forEach(input -> {
if (isLocalMixer(mixerId[0])) {
WaveLinkActions.setInputConfig(input.getIdentifier(),Status.localPackageName,"Volume",integerValue);
input.setLocalMixerLevel(integerValue);
Status.setInputValue(input.getName(),integerValue,"Local");
WaveLinkActions.setInputConfig(input.getIdentifier(),Status.localPackageName,"Volume", finalIntegerValue);
input.setLocalMixerLevel(finalIntegerValue);
Status.setInputValue(input.getName(), finalIntegerValue,"Local");
}
if (isStreamMixer(mixerId[0])) {
WaveLinkActions.setInputConfig(input.getIdentifier(), Status.streamPackageName, "Volume", integerValue);
input.setStreamMixerLevel(integerValue);
Status.setInputValue(input.getName(),integerValue,"Stream");
WaveLinkActions.setInputConfig(input.getIdentifier(), Status.streamPackageName, "Volume", finalIntegerValue);
input.setStreamMixerLevel(finalIntegerValue);
Status.setInputValue(input.getName(), finalIntegerValue,"Stream");
}
});
}
Expand Down Expand Up @@ -587,34 +613,78 @@ public void updateMics() {
}

//Mic actions
@Action(description = "Change mic gain, choose if you want to set it", format = "Mic: {$choices$} - {$options$} Gain: {$value$}",
@Action(description = "Change mic gain, choose if you want to set it", format = "Mic: {$choices$} - {$options$} Gain: {$valueString$}",
categoryId = "WaveLinkMics", name="Change Mic Gain")
private void actionSetMicrophoneGain(@Data(stateId = "micList") String[] choices, @Data(minValue = 0,maxValue = 40) Integer value,
private void actionSetMicrophoneGain(@Data(stateId = "micList") String[] choices, @Data() String valueString,
@Data(valueChoices = {"Set"}, defaultValue = "Set") String[] options) {
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetMicrophone received: " + " - " + choices[0] + " - " + value + " - " + options[0]);

Integer value = null;
try {
value = Integer.parseInt(valueString);
} catch (NumberFormatException e) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetMicrophoneGain value could not be converted to number");
return;
}
if (value < 0 || value > 40) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetMicrophoneGain value has to be between 0 and 40. It was " + value);
return;
}


WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetMicrophone received: " + " - " + choices[0] + " - " + valueString + " - " + options[0]);
WaveLinkActions.setMicOutputEnhancement("gain",choices[0],options[0],value);
}

@Action(description = "Change mic output volume, choose if you want to set it", format = "Mic: {$choices$} - {$options$} Volume: {$value$}",
@Action(description = "Change mic output volume, choose if you want to set it", format = "Mic: {$choices$} - {$options$} Volume: {$valueString$}",
categoryId = "WaveLinkMics", name="Change Mic Output Volume")
private void actionSetMicrophoneOutputVolume(@Data(stateId = "micList") String[] choices, @Data(minValue = 0,maxValue = 40) Integer value,
private void actionSetMicrophoneOutputVolume(@Data(stateId = "micList") String[] choices, @Data() String valueString,
@Data(valueChoices = {"Set"}, defaultValue = "Set") String[] options) {
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetMicrophoneOutputVolume received: " + choices[0] + " - " + value + " - " + options[0]);
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetMicrophoneOutputVolume received: " + choices[0] + " - " + valueString + " - " + options[0]);

Integer value = null;
try {
value = Integer.parseInt(valueString);
} catch (NumberFormatException e) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetMicrophoneOutputVolume value could not be converted to number");
return;
}
if (value < 0 || value > 40) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetMicrophoneOutputVolume value has to be between 0 and 40. It was " + value);
return;
}


WaveLinkActions.setMicOutputEnhancement("outputVolume",choices[0],options[0],value);
}

@Action(description = "Change mic PC/Mic mix volume, choose if you want to set it\n(0 is is closer to mic and 100 is closer to PC)", format = "Mic: {$choices$} - {$options$} Volume: {$value$}",
@Action(description = "Change mic PC/Mic mix volume, choose if you want to set it\n(0 is is closer to mic and 100 is closer to PC)", format = "Mic: {$choices$} - {$options$} Volume: {$valueString$}",
categoryId = "WaveLinkMics", name="Change Mic PC/Mic Mix Volume")
private void actionSetMicPcMix(@Data(stateId = "micList") String[] choices, @Data(minValue = 0,maxValue = 40) Integer value,
private void actionSetMicPcMix(@Data(stateId = "micList") String[] choices, @Data() String valueString,
@Data(valueChoices = {"Set"}, defaultValue = "Set") String[] options) {
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetMicPcMix received: " + choices[0] + " - " + value + " - " + options[0]);
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetMicPcMix received: " + choices[0] + " - " + valueString + " - " + options[0]);


Integer value = null;
try {
value = Integer.parseInt(valueString);
} catch (NumberFormatException e) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetMicPcMix value could not be converted to number");
return;
}
if (value < 0 || value > 40) {
WaveLinkPlugin.LOGGER.log(Level.WARNING, "actionSetMicPcMix value has to be between 0 and 40. It was " + value);
return;
}

WaveLinkActions.setMicOutputEnhancement("balance",choices[0],options[0],value);
}

@Action(format = "Toggle Clip Guard for Mic: {$choices$}",
categoryId = "WaveLinkMics", name="Toggle Clip Guard")
private void actionSetMicrophoneClipGuard(@Data(stateId = "micList") String[] choices) {
WaveLinkPlugin.LOGGER.log(Level.INFO, "Action actionSetMicrophoneClipGuard received: " + choices[0]);


WaveLinkActions.setMicOutputEnhancement("Microphone ClipGuard",choices[0],"Set",0);

}
Expand Down

0 comments on commit 0131146

Please sign in to comment.