Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

132 строки
4.4KB

  1. package rds
  2. // RDSConfig holds configuration data used to build the RDS data stream.
  3. // Covers IEC 62106 groups 0A, 2A, 3A, 4A, 10A, 11A, 14A (everything except TMC/EWS).
  4. type RDSConfig struct {
  5. // --- Group 0A: Basic tuning & switching ---
  6. // Program Identification – 16-bit station identifier.
  7. PI uint16
  8. // Program Service name (8 ASCII characters, padded with spaces).
  9. PS string
  10. // Program Type (0-31 standard RDS PTY values).
  11. PTY uint8
  12. // Traffic Program (TP) — this station carries traffic announcements.
  13. TP bool
  14. // Traffic Announcement (TA) — a traffic announcement is currently on air.
  15. // When TA transitions to true, receivers with TP-seek interrupt CD/other media.
  16. TA bool
  17. // Music/Speech switch: true = music, false = speech.
  18. // LEGACY: Deleted from IEC 62106-2:2018. Retained for pre-2018 receivers.
  19. MS bool
  20. // Decoder Identification (DI): 4-bit field sent across 4 group 0A segments.
  21. // bit 0 (d3): dynamic PTY (1) vs static (0) — ONLY THIS BIT REMAINS in IEC 62106-2:2018
  22. // bit 1-3: stereo/artificial head/compressed — DELETED from standard
  23. // LEGACY: Only dynamic PTY indicator (bit 3) is current standard.
  24. DI uint8
  25. // Long Programme Service name (LPS) — Group Type 15A, IEC 62106-2:2018.
  26. // Up to 32 bytes UTF-8, max ~16 display characters. Static station name.
  27. // Complements PS (8 chars); receivers may display LPS instead of PS.
  28. // Runs on Stream 0 — no RDS2 required.
  29. LPS string
  30. // Alternative Frequencies list. Up to 25 frequencies in MHz (e.g. 93.3, 95.7).
  31. // Transmitted in group 0A block C (two AF codes per group).
  32. // Enables automatic retuning when signal weakens.
  33. AF []float64
  34. // --- Group 2A: RadioText ---
  35. // RadioText (up to 64 characters). Current song, info, etc.
  36. RT string
  37. // --- Group 4A: Clock-Time & Date ---
  38. // CTEnabled: transmit UTC clock-time once per minute.
  39. CTEnabled bool
  40. // CTOffsetHalfHours: local time offset from UTC in half-hours (-24..+24).
  41. // E.g. CET = +2, CEST = +4. Auto-detected from OS if zero.
  42. CTOffsetHalfHours int8
  43. // --- Group 10A: Program Type Name ---
  44. // PTYN: 8-character custom label for the program type.
  45. // Overrides the standard PTY label on receivers that support it.
  46. // Empty = don't transmit group 10A.
  47. PTYN string
  48. // --- Group 11A + 3A: RT+ (RadioText Plus) ---
  49. // RTPlusEnabled: automatically parse RT into semantic tags (artist, title, etc.)
  50. // and transmit RT+ groups (11A) with ODA announcements (3A).
  51. RTPlusEnabled bool
  52. // RTPlusSeparator: string used to split RT into artist/title.
  53. // Default "-". E.g. "Depeche Mode - Enjoy The Silence" → artist/title.
  54. RTPlusSeparator string
  55. // --- eRT: Enhanced RadioText (ODA, AID 0x6552) ---
  56. // ERTEnabled: transmit eRT as ODA on Stream 0 (parallel to RT).
  57. ERTEnabled bool
  58. // ERT: UTF-8 text, max 128 bytes. For non-Latin scripts (Cyrillic, Arabic, CJK).
  59. ERT string
  60. // ERTGroupType: allocated group type for eRT data (default 12).
  61. ERTGroupType uint8
  62. // --- RDS2 (Streams 1-3, IEC 62106-1:2018) ---
  63. // RDS2Enabled: activate additional subcarriers (66.5, 71.25, 76 kHz).
  64. RDS2Enabled bool
  65. // StationLogoPath: PNG/JPEG file. Transmitted via RFT on RDS2 streams.
  66. StationLogoPath string
  67. // --- Group 14A/14B: Enhanced Other Networks (EON) ---
  68. // EON: information about other stations in the network.
  69. // Enables cross-station TA switching and AF lists for other programs.
  70. EON []EONEntry
  71. // --- Encoder internal ---
  72. // SampleRate that the encoder will work against. Defaults to 228000 when zero.
  73. SampleRate float64
  74. }
  75. // EONEntry describes another station in the network for EON (group 14A/14B).
  76. type EONEntry struct {
  77. PI uint16 // Program Identification of the other station
  78. PS string // Program Service name (8 chars)
  79. PTY uint8 // Program Type
  80. TP bool // Traffic Program flag
  81. TA bool // Traffic Announcement flag (live-updated for cross-TA switching)
  82. AF []float64 // Alternative Frequencies for the other station
  83. }
  84. // DefaultConfig returns a minimal config with sane defaults.
  85. func DefaultConfig() RDSConfig {
  86. return RDSConfig{
  87. PI: 0x1234,
  88. PS: "FM-RDS",
  89. RT: "Go-based MPX",
  90. PTY: 0,
  91. TP: false,
  92. TA: false,
  93. MS: true, // music by default
  94. DI: 0x01, // stereo
  95. CTEnabled: true,
  96. RTPlusEnabled: true,
  97. RTPlusSeparator: " - ",
  98. ERTGroupType: 12, // Group 12A for eRT data
  99. SampleRate: 228000,
  100. }
  101. }