Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

110 lines
3.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. // Receivers may adjust EQ or display accordingly.
  19. MS bool
  20. // Decoder Identification (DI): 4-bit field sent across 4 group 0A segments.
  21. // bit 0 (d3): stereo (1) vs mono (0)
  22. // bit 1 (d2): artificial head (1) vs normal (0)
  23. // bit 2 (d1): compressed (1) vs not (0)
  24. // bit 3 (d0): dynamic PTY (1) vs static (0)
  25. DI uint8
  26. // Alternative Frequencies list. Up to 25 frequencies in MHz (e.g. 93.3, 95.7).
  27. // Transmitted in group 0A block C (two AF codes per group).
  28. // Enables automatic retuning when signal weakens.
  29. AF []float64
  30. // --- Group 2A: RadioText ---
  31. // RadioText (up to 64 characters). Current song, info, etc.
  32. RT string
  33. // --- Group 4A: Clock-Time & Date ---
  34. // CTEnabled: transmit UTC clock-time once per minute.
  35. CTEnabled bool
  36. // CTOffsetHalfHours: local time offset from UTC in half-hours (-24..+24).
  37. // E.g. CET = +2, CEST = +4. Auto-detected from OS if zero.
  38. CTOffsetHalfHours int8
  39. // --- Group 10A: Program Type Name ---
  40. // PTYN: 8-character custom label for the program type.
  41. // Overrides the standard PTY label on receivers that support it.
  42. // Empty = don't transmit group 10A.
  43. PTYN string
  44. // --- Group 11A + 3A: RT+ (RadioText Plus) ---
  45. // RTPlusEnabled: automatically parse RT into semantic tags (artist, title, etc.)
  46. // and transmit RT+ groups (11A) with ODA announcements (3A).
  47. RTPlusEnabled bool
  48. // RTPlusSeparator: string used to split RT into artist/title.
  49. // Default "-". E.g. "Depeche Mode - Enjoy The Silence" → artist/title.
  50. RTPlusSeparator string
  51. // --- Group 14A/14B: Enhanced Other Networks (EON) ---
  52. // EON: information about other stations in the network.
  53. // Enables cross-station TA switching and AF lists for other programs.
  54. EON []EONEntry
  55. // --- Encoder internal ---
  56. // SampleRate that the encoder will work against. Defaults to 228000 when zero.
  57. SampleRate float64
  58. }
  59. // EONEntry describes another station in the network for EON (group 14A/14B).
  60. type EONEntry struct {
  61. PI uint16 // Program Identification of the other station
  62. PS string // Program Service name (8 chars)
  63. PTY uint8 // Program Type
  64. TP bool // Traffic Program flag
  65. TA bool // Traffic Announcement flag (live-updated for cross-TA switching)
  66. AF []float64 // Alternative Frequencies for the other station
  67. }
  68. // DefaultConfig returns a minimal config with sane defaults.
  69. func DefaultConfig() RDSConfig {
  70. return RDSConfig{
  71. PI: 0x1234,
  72. PS: "FM-RDS",
  73. RT: "Go-based MPX",
  74. PTY: 0,
  75. TP: false,
  76. TA: false,
  77. MS: true, // music by default
  78. DI: 0x01, // stereo
  79. CTEnabled: true,
  80. RTPlusEnabled: true,
  81. RTPlusSeparator: " - ",
  82. SampleRate: 228000,
  83. }
  84. }