mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-21 13:05:43 -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();
|
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.
|
* 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()
|
private void updateMuted()
|
||||||
{
|
{
|
||||||
@@ -313,6 +313,11 @@ public class AudioView extends HBox
|
|||||||
muted &= view.getAudioChannel().isMuted();
|
muted &= view.getAudioChannel().isMuted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(AudioChannelView view: mChannelViews)
|
||||||
|
{
|
||||||
|
view.setOutputMuted(muted);
|
||||||
|
}
|
||||||
|
|
||||||
mMuteButton.setSelected(muted);
|
mMuteButton.setSelected(muted);
|
||||||
mMuteIcon.setIconCode(muted ? FontAwesome.VOLUME_OFF : FontAwesome.VOLUME_UP);
|
mMuteIcon.setIconCode(muted ? FontAwesome.VOLUME_OFF : FontAwesome.VOLUME_UP);
|
||||||
mMuteButton.setTooltip(new Tooltip(muted ? "Unmute all audio" : "Mute all audio"));
|
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
|
* 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
|
public class LevelMeter extends Region
|
||||||
{
|
{
|
||||||
@@ -70,6 +71,10 @@ public class LevelMeter extends Region
|
|||||||
setPrefHeight(PREFERRED_HEIGHT);
|
setPrefHeight(PREFERRED_HEIGHT);
|
||||||
setMaxHeight(PREFERRED_HEIGHT);
|
setMaxHeight(PREFERRED_HEIGHT);
|
||||||
setMinWidth(40);
|
setMinWidth(40);
|
||||||
|
disabledProperty().addListener((observable, wasDisabled, disabled) -> {
|
||||||
|
updateOpacity();
|
||||||
|
reset();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,6 +83,11 @@ public class LevelMeter extends Region
|
|||||||
*/
|
*/
|
||||||
public void update(float peak)
|
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 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);
|
double level = Math.max(db, mLevelDb - mFallPerUpdateDb);
|
||||||
|
|
||||||
@@ -111,10 +121,15 @@ public class LevelMeter extends Region
|
|||||||
if(mDimmed != dimmed)
|
if(mDimmed != dimmed)
|
||||||
{
|
{
|
||||||
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.
|
* Resets the meter to silence.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user