Synthia
Generic and flexible data structure generator
FMRadio.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 examples.oscilloscope;
20 
21 import ca.uqac.lif.synthia.Picker;
25 import ca.uqac.lif.synthia.util.Offset;
26 import ca.uqac.lif.synthia.util.Tick;
28 
29 /**
30  * Illustrates the principle of
31  * <a href="https://en.wikipedia.org/wiki/Frequency_modulation">frequency
32  * modulation</a> using sine wave and prism pickers. In this example,
33  * the signal to modulate and the carrier wave can be shown on the
34  * {@link Oscilloscope} respectively as:
35  * <p>
36  * <img src="./doc-files/oscilloscope/Signal.png" alt="Signal" />
37  * <img src="./doc-files/oscilloscope/FM_Carrier.png" alt="Carrier" />
38  * <p>
39  * The wiring diagram of pickers corresponding to frequency modulation is
40  * as follows:
41  * <p>
42  * <img src="./doc-files/oscilloscope/FMRadio.png" alt="Picker wiring diagram" />
43  * <p>
44  * When running the program, the resulting modulated signal is shown on
45  * the oscilloscope:
46  * <p>
47  * <img src="./doc-files/oscilloscope/FM_Modulated.png" alt="Modulated signal" />
48  * <p>
49  * As one can see, the amplitude of the signal does not change, but its
50  * frequency does; this corresponds to the varying width of each cycle of the
51  * carrier.
52  *
53  * @ingroup Examples
54  */
55 public class FMRadio
56 {
57  @SuppressWarnings("unchecked")
58  public static void main(String[] args)
59  {
60  // Generator for x-coordinate
61  Picker<Number> x = new Tick(-1, 0.0001);
62  // The signal to modulate
63  SineWave signal = new SineWave(
64  new Constant<Number>(1),
65  new Tick(0, 0.00075),
66  new Constant<Number>(0)
67  );
68  // Generator for y-coordinate
69  SineWave y = new SineWave(
70  new Constant<Number>(1), // amplitude
71  new Offset(new Tick(0, 0.002), signal), // frequency
72  new Constant<Number>(0) // phase
73  );
74  // Create a list of 500 points out of x and y values
75  PrismPicker points = new PrismPicker(x, y);
76  ComposeList<float[]> set = new ComposeList<float[]>(points, 20000);
77  // Display these points in our "oscilloscope"
78  Oscilloscope o = new Oscilloscope().addPoints(set.pick());
79  o.setVisible(true);
80  }
81 }
ca.uqac.lif.synthia.Picker
Picks an object.
Definition: Picker.java:36
examples.oscilloscope.Oscilloscope.addPoints
Oscilloscope addPoints(List< float[]> points)
Definition: Oscilloscope.java:68
ca.uqac.lif.synthia.collection
Pickers generating and manipulating collections, such as lists and sets.
Definition: ComparableList.java:19
ca.uqac.lif.synthia.util
Miscellaneous pickers performing various functions.
Definition: ArrayPicker.java:19
ca.uqac.lif.synthia.vector.PrismPicker
Generates a vector by independently picking a value for each of its coordinates.
Definition: PrismPicker.java:38
examples.oscilloscope.FMRadio
Illustrates the principle of frequency modulation using sine wave and prism pickers.
Definition: FMRadio.java:55
ca.uqac.lif.synthia.vector
Pickers generating multi-dimensional numerical vectors.
Definition: HyperspherePicker.java:19
ca.uqac
ca.uqac.lif.synthia
Definition: Bounded.java:19
ca.uqac.lif.synthia.util.Constant
Picker that returns the same object every time.
Definition: Constant.java:37
ca.uqac.lif.synthia.signal
Pickers producing values representing a form of (periodic) signal.
Definition: package-info.java:24
examples.oscilloscope.Oscilloscope
A simple JFrame that simulates the operation of an oscilloscope.
Definition: Oscilloscope.java:46
ca.uqac.lif
ca.uqac.lif.synthia.util.Tick
Generates a sequence of monotonically increasing numerical values.
Definition: Tick.java:51
ca
examples.oscilloscope.FMRadio.main
static void main(String[] args)
Definition: FMRadio.java:58
ca.uqac.lif.synthia.signal.SineWave
A periodic signal picker producing a sine wave.
Definition: SineWave.java:28
ca.uqac.lif.synthia.util.Offset
Takes the numerical value of a picker, and offsets it by an amount determined by another picker.
Definition: Offset.java:28
ca.uqac.lif.synthia.collection.ComposeList
Definition: ComposeList.java:44