Synthia
Generic and flexible data structure generator
AMRadio.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.Tick;
27 
28 /**
29  * Illustrates the principle of
30  * <a href="https://en.wikipedia.org/wiki/Amplitude_modulation">amplitude
31  * modulation</a> using sine wave and prism pickers. In this example,
32  * the signal to modulate and the carrier wave can be shown on the
33  * {@link Oscilloscope} respectively as:
34  * <p>
35  * <img src="./doc-files/oscilloscope/Signal.png" alt="Signal" />
36  * <img src="./doc-files/oscilloscope/AM_Carrier.png" alt="Carrier" />
37  * <p>
38  * The wiring diagram of pickers corresponding to amplitude modulation is
39  * as follows:
40  * <p>
41  * <img src="./doc-files/oscilloscope/AMRadio.png" alt="Picker wiring diagram" />
42  * <p>
43  * When running the program, the resulting modulated signal is shown on
44  * the oscilloscope:
45  * <p>
46  * <img src="./doc-files/oscilloscope/AM_Modulated.png" alt="Modulated signal" />
47  * <p>
48  * As one can see, the frequency of the signal does not change, but its
49  * amplitude does; this corresponds to the varying height of each cycle of the
50  * carrier.
51  *
52  * @ingroup Examples
53  */
54 public class AMRadio
55 {
56  @SuppressWarnings("unchecked")
57  public static void main(String[] args)
58  {
59  // Generator for x-coordinate
60  Picker<Number> x = new Tick(-1, 0.0001);
61  // The signal to modulate
62  SineWave signal = new SineWave(
63  new Constant<Number>(1),
64  new Tick(0, 0.00075),
65  new Constant<Number>(0)
66  );
67  // Generator for y-coordinate
68  SineWave y = new SineWave(
69  signal, // amplitude
70  new Tick(0, 0.01), // frequency
71  new Constant<Number>(0) // phase
72  );
73  // Create a list of 500 points out of x and y values
74  PrismPicker points = new PrismPicker(x, y);
75  ComposeList<float[]> set = new ComposeList<float[]>(points, 20000);
76  // Display these points in our "oscilloscope"
77  Oscilloscope o = new Oscilloscope().addPoints(set.pick());
78  o.setVisible(true);
79  }
80 }
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.AMRadio
Illustrates the principle of amplitude modulation using sine wave and prism pickers.
Definition: AMRadio.java:54
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
ca.uqac.lif.synthia.signal.SineWave
A periodic signal picker producing a sine wave.
Definition: SineWave.java:28
examples.oscilloscope.AMRadio.main
static void main(String[] args)
Definition: AMRadio.java:57
ca.uqac.lif.synthia.collection.ComposeList
Definition: ComposeList.java:44