Skip to content

Instantly share code, notes, and snippets.

@benharri
Last active April 4, 2022 17:13
Show Gist options
  • Save benharri/f7dd48a5d0a7be522b52e6c5630ec141 to your computer and use it in GitHub Desktop.
Save benharri/f7dd48a5d0a7be522b52e6c5630ec141 to your computer and use it in GitHub Desktop.
ircpuzzles 2021 08
namespace morse;
public enum Morse
{
Dot,
Dash,
Space,
WordSeparator,
None
}
public static class Program
{
public static void Main()
{
// export tags from audacity
// <starttime>\t<endtime>\t<label>
var ticks = File.ReadLines(@"ticks.txt");
var time = 0.0;
List<Morse> symbols = new();
foreach (var line in ticks)
{
var split = line.Split('\t', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
var start = float.Parse(split[0]);
var duration = start - time;
Console.WriteLine($"{duration:F2}");
symbols.Add(duration switch
{
// >= 1.0 => Morse.WordSeparator,
>= 1.0 => Morse.Space,
>= 0.7 => Morse.Dash,
>= 0.3 => Morse.Dot,
_ => Morse.None,
});
time = start;
}
foreach (var symbol in symbols.Where(symbol => symbol != Morse.None))
{
if (symbol is Morse.WordSeparator or Morse.Space)
{
Console.WriteLine();
continue;
}
Console.Write($"{symbol} ");
}
}
}
0.080000 0.080000 Sound 01
0.400000 0.400000 Sound 02
0.880000 0.880000 Sound 03
1.600000 1.600000 Sound 04
2.080000 2.080000 Sound 05
2.800000 2.800000 Sound 06
4.080000 4.080000 Sound 07
4.400000 4.400000 Sound 08
4.880000 4.880000 Sound 09
5.200000 5.200000 Sound 10
5.680000 5.680000 Sound 11
6.000000 6.000000 Sound 12
6.480000 6.480000 Sound 13
6.800000 6.800000 Sound 14
8.080000 8.080000 Sound 15
8.400000 8.400000 Sound 16
8.880000 8.880000 Sound 17
9.600000 9.600000 Sound 18
10.880000 10.880000 Sound 19
11.600000 11.600000 Sound 20
13.680000 13.680000 Sound 21
14.000000 14.000000 Sound 22
14.480000 14.480000 Sound 23
14.800000 14.800000 Sound 24
15.280000 15.280000 Sound 25
15.600000 15.600000 Sound 26
16.080000 16.080000 Sound 27
16.400000 16.400000 Sound 28
17.680000 17.680000 Sound 29
18.000000 18.000000 Sound 30
18.480000 18.480000 Sound 31
19.200000 19.200000 Sound 32
20.480000 20.480000 Sound 33
21.200000 21.200000 Sound 34
22.480000 22.480000 Sound 35
22.800000 22.800000 Sound 36
23.280000 23.280000 Sound 37
23.600000 23.600000 Sound 38
24.080000 24.080000 Sound 39
24.400000 24.400000 Sound 40
24.880000 24.880000 Sound 41
25.200000 25.200000 Sound 42
27.280000 27.280000 Sound 43
28.000000 28.000000 Sound 44
28.480000 28.480000 Sound 45
29.200000 29.200000 Sound 46
29.680000 29.680000 Sound 47
30.000000 30.000000 Sound 48
31.280000 31.280000 Sound 49
31.600000 31.600000 Sound 50
32.480000 32.480000 Sound 51
32.800000 32.800000 Sound 52
34.080000 34.080000 Sound 53
34.800000 34.800000 Sound 54
35.280000 35.280000 Sound 55
35.600000 35.600000 Sound 56
36.080000 36.080000 Sound 57
36.400000 36.400000 Sound 58
38.480000 38.480000 Sound 59
38.800000 38.800000 Sound 60
39.280000 39.280000 Sound 61
40.000000 40.000000 Sound 62
40.480000 40.480000 Sound 63
41.200000 41.200000 Sound 64
42.480000 42.480000 Sound 65
42.800000 42.800000 Sound 66
43.680000 43.680000 Sound 67
44.000000 44.000000 Sound 68
44.480000 44.480000 Sound 69
44.800000 44.800000 Sound 70
46.080000 46.080000 Sound 71
46.400000 46.400000 Sound 72
47.280000 47.280000 Sound 73
47.600000 47.600000 Sound 74
48.880000 48.880000 Sound 75
49.200000 49.200000 Sound 76
49.680000 49.680000 Sound 77
50.000000 50.000000 Sound 78
50.480000 50.480000 Sound 79
51.200000 51.200000 Sound 80
52.480000 52.480000 Sound 81
53.200000 53.200000 Sound 82
53.680000 53.680000 Sound 83
54.400000 54.400000 Sound 84
54.880000 54.880000 Sound 85
55.200000 55.200000 Sound 86
56.480000 56.480000 Sound 87
56.800000 56.800000 Sound 88
57.280000 57.280000 Sound 89
57.600000 57.600000 Sound 90
58.080000 58.080000 Sound 91
58.400000 58.400000 Sound 92
58.880000 58.880000 Sound 93
59.200000 59.200000 Sound 94
60.480000 60.480000 Sound 95
61.200000 61.200000 Sound 96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment