mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-21 04:55:55 -05:00
Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
@@ -242,6 +242,15 @@ public class AudioChannelView extends HBox
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the level meter while the whole audio output (every channel) is muted.
|
||||
* @param outputMuted true when every channel is muted
|
||||
*/
|
||||
public void setOutputMuted(boolean outputMuted)
|
||||
{
|
||||
mLevelMeter.setDisable(outputMuted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the muted display after the channel or the whole output was (un)muted.
|
||||
*/
|
||||
|
||||
@@ -302,7 +302,7 @@ public class AudioView extends HBox
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the master mute button. The output is muted when every channel is muted.
|
||||
* Updates the master mute button and disables the channel level meters when every channel is muted.
|
||||
*/
|
||||
private void updateMuted()
|
||||
{
|
||||
@@ -313,6 +313,11 @@ public class AudioView extends HBox
|
||||
muted &= view.getAudioChannel().isMuted();
|
||||
}
|
||||
|
||||
for(AudioChannelView view: mChannelViews)
|
||||
{
|
||||
view.setOutputMuted(muted);
|
||||
}
|
||||
|
||||
mMuteButton.setSelected(muted);
|
||||
mMuteIcon.setIconCode(muted ? FontAwesome.VOLUME_OFF : FontAwesome.VOLUME_UP);
|
||||
mMuteButton.setTooltip(new Tooltip(muted ? "Unmute all audio" : "Mute all audio"));
|
||||
|
||||
@@ -26,7 +26,8 @@ import javafx.scene.paint.Color;
|
||||
|
||||
/**
|
||||
* Segmented horizontal audio level meter in dBFS with peak hold and level ballistics. Feed it with peak sample
|
||||
* levels via {@link #update(float)} at a steady rate from the JavaFX application thread.
|
||||
* levels via {@link #update(float)} at a steady rate from the JavaFX application thread. While the meter is
|
||||
* disabled, for example when the whole audio output is muted, it shows silence and ignores updates.
|
||||
*/
|
||||
public class LevelMeter extends Region
|
||||
{
|
||||
@@ -70,6 +71,10 @@ public class LevelMeter extends Region
|
||||
setPrefHeight(PREFERRED_HEIGHT);
|
||||
setMaxHeight(PREFERRED_HEIGHT);
|
||||
setMinWidth(40);
|
||||
disabledProperty().addListener((observable, wasDisabled, disabled) -> {
|
||||
updateOpacity();
|
||||
reset();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,6 +83,11 @@ public class LevelMeter extends Region
|
||||
*/
|
||||
public void update(float peak)
|
||||
{
|
||||
if(isDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double db = peak > 0.0f ? Math.max(MINIMUM_DB, Math.min(MAXIMUM_DB, 20.0 * Math.log10(peak))) : MINIMUM_DB;
|
||||
double level = Math.max(db, mLevelDb - mFallPerUpdateDb);
|
||||
|
||||
@@ -111,10 +121,15 @@ public class LevelMeter extends Region
|
||||
if(mDimmed != dimmed)
|
||||
{
|
||||
mDimmed = dimmed;
|
||||
mCanvas.setOpacity(dimmed ? 0.45 : 1.0);
|
||||
updateOpacity();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOpacity()
|
||||
{
|
||||
mCanvas.setOpacity(isDisabled() ? 0.3 : mDimmed ? 0.45 : 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the meter to silence.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user