Synthia
Generic and flexible data structure generator
SineWave.java
Go to the documentation of this file.
1 /*
2  Synthia, a data structure generator
3  Copyright (C) 2019-2021 Laboratoire d'informatique formelle
4  Université du Québec à Chicoutimi, Canada
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 package ca.uqac.lif.synthia.signal;
20 
21 import ca.uqac.lif.synthia.Picker;
22 
23 /**
24  * A periodic signal picker producing a sine wave.
25  * @author Sylvain Hallé
26  * @ingroup API
27  */
28 public class SineWave extends PeriodicSignal
29 {
30  public SineWave(/*@ non_null @*/ Picker<? extends Number> amplitude, /*@ non_null @*/ Picker<? extends Number> frequency, /*@ non_null @*/ Picker<? extends Number> phase)
31  {
32  super(amplitude, frequency, phase);
33  }
34 
35  @Override
36  public Float pick()
37  {
38  return m_amplitude.pick().floatValue() * (float) Math.sin(m_frequency.pick().floatValue() + m_phase.pick().floatValue());
39  }
40 
41  @Override
42  public SineWave duplicate(boolean with_state)
43  {
44  SineWave s = new SineWave(m_amplitude.duplicate(with_state), m_frequency.duplicate(with_state), m_phase.duplicate(with_state));
45  super.copyInto(s, with_state);
46  return s;
47  }
48 }
ca.uqac.lif.synthia.Picker
Picks an object.
Definition: Picker.java:36
ca.uqac.lif.synthia.signal.PeriodicSignal.m_phase
Picker<? extends Number > m_phase
A picker determining the phase of the signal.
Definition: PeriodicSignal.java:43
ca.uqac.lif.synthia.signal.PeriodicSignal
A signal picker that is characterized by an amplitude and a phase.
Definition: PeriodicSignal.java:28
ca.uqac
ca.uqac.lif.synthia.signal.SineWave.pick
Float pick()
Picks an object.
Definition: SineWave.java:36
ca.uqac.lif.synthia
Definition: Bounded.java:19
ca.uqac.lif.synthia.signal.SineWave.duplicate
SineWave duplicate(boolean with_state)
Creates a copy of the picker.
Definition: SineWave.java:42
ca.uqac.lif
ca
ca.uqac.lif.synthia.Picker.pick
T pick()
Picks an object.
ca.uqac.lif.synthia.signal.SineWave.SineWave
SineWave(Picker<? extends Number > amplitude, Picker<? extends Number > frequency, Picker<? extends Number > phase)
Definition: SineWave.java:30
ca.uqac.lif.synthia.signal.PeriodicSignal.m_amplitude
Picker<? extends Number > m_amplitude
A picker determining the amplitude of the signal.
Definition: PeriodicSignal.java:33
ca.uqac.lif.synthia.signal.SineWave
A periodic signal picker producing a sine wave.
Definition: SineWave.java:28
ca.uqac.lif.synthia.signal.PeriodicSignal.m_frequency
Picker<? extends Number > m_frequency
A picker determining the frequency of the signal.
Definition: PeriodicSignal.java:38
ca.uqac.lif.synthia.Picker.duplicate
Picker< T > duplicate(boolean with_state)
Creates a copy of the picker.