11/*
2- * Copyright (c) 2009-2023 jMonkeyEngine
2+ * Copyright (c) 2009-2025 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
3636import com .jme3 .export .JmeImporter ;
3737import com .jme3 .export .OutputCapsule ;
3838import com .jme3 .util .NativeObject ;
39+
3940import java .io .IOException ;
4041
42+ /**
43+ * A filter that attenuates frequencies above a specified threshold, allowing lower
44+ * frequencies to pass through with less attenuation. Commonly used to simulate effects
45+ * such as muffling or underwater acoustics.
46+ */
4147public class LowPassFilter extends Filter {
4248
43- protected float volume , highFreqVolume ;
49+ /**
50+ * The overall volume scaling of the filtered sound
51+ */
52+ protected float volume ;
53+ /**
54+ * The volume scaling of the high frequencies allowed to pass through. Valid values range
55+ * from 0.0 to 1.0, where 0.0 completely eliminates high frequencies and 1.0 lets them pass
56+ * through unchanged.
57+ */
58+ protected float highFreqVolume ;
4459
60+ /**
61+ * Constructs a low-pass filter.
62+ *
63+ * @param volume the overall volume scaling of the filtered sound (0.0 - 1.0).
64+ * @param highFreqVolume the volume scaling of high frequencies (0.0 - 1.0).
65+ * @throws IllegalArgumentException if {@code volume} or {@code highFreqVolume} is out of range.
66+ */
4567 public LowPassFilter (float volume , float highFreqVolume ) {
4668 super ();
4769 setVolume (volume );
4870 setHighFreqVolume (highFreqVolume );
4971 }
5072
73+ /**
74+ * For internal cloning
75+ * @param id the native object ID
76+ */
5177 protected LowPassFilter (int id ) {
5278 super (id );
5379 }
5480
81+ /**
82+ * Retrieves the current volume scaling of high frequencies.
83+ *
84+ * @return the high-frequency volume scaling.
85+ */
5586 public float getHighFreqVolume () {
5687 return highFreqVolume ;
5788 }
5889
90+ /**
91+ * Sets the high-frequency volume.
92+ *
93+ * @param highFreqVolume the new high-frequency volume scaling (0.0 - 1.0).
94+ * @throws IllegalArgumentException if {@code highFreqVolume} is out of range.
95+ */
5996 public void setHighFreqVolume (float highFreqVolume ) {
6097 if (highFreqVolume < 0 || highFreqVolume > 1 )
6198 throw new IllegalArgumentException ("High freq volume must be between 0 and 1" );
@@ -64,10 +101,21 @@ public void setHighFreqVolume(float highFreqVolume) {
64101 this .updateNeeded = true ;
65102 }
66103
104+ /**
105+ * Retrieves the current overall volume scaling of the filtered sound.
106+ *
107+ * @return the overall volume scaling.
108+ */
67109 public float getVolume () {
68110 return volume ;
69111 }
70112
113+ /**
114+ * Sets the overall volume.
115+ *
116+ * @param volume the new overall volume scaling (0.0 - 1.0).
117+ * @throws IllegalArgumentException if {@code volume} is out of range.
118+ */
71119 public void setVolume (float volume ) {
72120 if (volume < 0 || volume > 1 )
73121 throw new IllegalArgumentException ("Volume must be between 0 and 1" );
@@ -92,11 +140,21 @@ public void read(JmeImporter im) throws IOException {
92140 highFreqVolume = ic .readFloat ("hf_volume" , 0 );
93141 }
94142
143+ /**
144+ * Creates a native object clone of this filter for internal usage.
145+ *
146+ * @return a new {@code LowPassFilter} instance with the same native ID.
147+ */
95148 @ Override
96149 public NativeObject createDestructableClone () {
97150 return new LowPassFilter (id );
98151 }
99152
153+ /**
154+ * Retrieves a unique identifier for this filter. Used internally for native object management.
155+ *
156+ * @return a unique long identifier.
157+ */
100158 @ Override
101159 public long getUniqueId () {
102160 return ((long ) OBJTYPE_FILTER << 32 ) | (0xffffffffL & (long ) id );
0 commit comments