morsecode
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| morsecode [2026/05/05 14:27] – frchris | morsecode [2026/05/05 14:40] (current) – frchris | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ==== ToneTester ==== | ==== ToneTester ==== | ||
| This demonstrates how to generate a morse code tone. The timing is all based on the length of the " | This demonstrates how to generate a morse code tone. The timing is all based on the length of the " | ||
| + | |||
| + | ToneTester demonstrates how to use the javax sound | ||
| + | | ||
| + | which is what a HAM radio operator will | ||
| + | call to seek out a conversation from | ||
| + | | ||
| <code java ToneTester.java> | <code java ToneTester.java> | ||
| - | |||
| import javax.sound.sampled.AudioFormat; | import javax.sound.sampled.AudioFormat; | ||
| import javax.sound.sampled.AudioSystem; | import javax.sound.sampled.AudioSystem; | ||
| import javax.sound.sampled.SourceDataLine; | import javax.sound.sampled.SourceDataLine; | ||
| - | |||
| public class ToneTester { | public class ToneTester { | ||
| /** | /** | ||
| - | * @param args | + | * ToneTester demonstrates how to use the javax sound |
| - | * @throws Exception | + | * library to generate a morse code "CQ CQ" |
| + | * which is what a HAM radio operator will | ||
| + | * call to seek out a conversation from | ||
| + | * anyone who might be able to be listening | ||
| + | * | ||
| + | * @author Chris Thiel, ofmCap | ||
| + | * @version May 5, 2026 | ||
| */ | */ | ||
| Line 36: | Line 46: | ||
| int[] c = {dah, di, dah, dit}; | int[] c = {dah, di, dah, dit}; | ||
| int[] q = {dah, dah, di, dah}; | int[] q = {dah, dah, di, dah}; | ||
| + | int[][] cq = {c,q}; | ||
| for (int i = 0; i < 2; i++) { | for (int i = 0; i < 2; i++) { | ||
| - | play(c); | + | playWord(cq); |
| - | play(q); | + | |
| } | } | ||
| Line 79: | Line 89: | ||
| { | { | ||
| double angle = i / (frequency / hz1)* tau; | double angle = i / (frequency / hz1)* tau; | ||
| - | |||
| buf[0] = (byte) (Math.sin(angle) * volume); | buf[0] = (byte) (Math.sin(angle) * volume); | ||
| - | |||
| sdl.write(buf, | sdl.write(buf, | ||
| } | } | ||
morsecode.1778005630.txt.gz · Last modified: by frchris
