File tree Expand file tree Collapse file tree
AudioCoder/src/main/java/org/operatorfoundation/audiocoder/mfsk Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ sealed class MFSKMode(
5454 /* *
5555 * MFSK-16: 16 tones, 15.625 baud, 250 Hz bandwidth.
5656 * The most common MFSK mode. Same baud rate as [MFSK8] but carries 4 bits per symbol
57- * instead of 3. Primary target mode for Nahoft.
57+ * instead of 3.
5858 */
5959 object MFSK16 : MFSKMode(
6060 toneCount = 16 ,
@@ -164,4 +164,27 @@ sealed class MFSKMode(
164164 // -------------------------------------------------------------------------
165165
166166 override fun toString (): String = label
167+
168+ // -------------------------------------------------------------------------
169+ // Serialization helpers
170+ // -------------------------------------------------------------------------
171+
172+ companion object
173+ {
174+ /* *
175+ * Returns the [MFSKMode] corresponding to [label], or null if no match.
176+ *
177+ * [label] must match the format produced by [MFSKMode.label] — e.g. `"MFSK-16"`.
178+ * Use this to reconstruct a mode from an Intent extra or other string representation.
179+ */
180+ fun fromLabel (label : String ): MFSKMode ? = when (label)
181+ {
182+ MFSK8 .label -> MFSK8
183+ MFSK16 .label -> MFSK16
184+ MFSK32 .label -> MFSK32
185+ MFSK64 .label -> MFSK64
186+ MFSK128 .label -> MFSK128
187+ else -> null
188+ }
189+ }
167190}
You can’t perform that action at this time.
0 commit comments