diff --git a/android/app/src/main/assets/phone/companion.html b/android/app/src/main/assets/phone/companion.html index 537d5d92..555da794 100644 --- a/android/app/src/main/assets/phone/companion.html +++ b/android/app/src/main/assets/phone/companion.html @@ -641,11 +641,14 @@ function director() {
${a.titles.slice(0, 6).map(t => `
${esc(t.title)}${t.year ? ` ${t.year}` : ''}
`).join('')}${a.titles.length > 6 ? `
and ${a.titles.length - 6} more
` : ''}
`).join(''); h += '
Titles for your channels
'; + const later = () => (state.unplayable?.length ? `
Won't play on this TV
` + state.unplayable.map(u => `

${esc(u.title)}

+
${u.channel ? 'Channel ' + u.channel + ' · ' : ''}${esc(u.reason)}
+
`).join('') : ''); h += r.choices.length ? r.choices.map(c => `

${esc(c.title)}

${c.type === 'Movie' ? 'Film' : 'Series'}${c.year ? ' · ' + c.year : ''}${c.line ? ' · ' + esc(c.line) : ''}
${c.options.map((o, k) => ``).join('')}
${c.options[0]?.reason ? `
${esc(c.options[0].reason)}
` : ''}
`).join('') : '
Nothing new to place this week.
'; - return h + '
Placing adds a title to that channel\'s list; it joins as the channel plans ahead, and nothing already booked changes.
'; + return h + '
Placing adds a title to that channel\'s list; it joins as the channel plans ahead, and nothing already booked changes.
' + later(); } // Add to home screen (Paul, 6 November 2026): offered once after joining, and any time from More. The TV's page is plain @@ -684,7 +687,8 @@ async function load(what) { if (what === 'more') { const [l, c, p] = await Promise.all([api('/api/looks'), api('/api/channels').catch(() => null), api('/api/profiles').catch(() => null)]); state.looks = l.looks; state.channels = c; state.profiles = p; look(state.now?.look); if (p?.current?.kind !== 'Kids') api('/api/director').then(r => { state.directorCount = r.ready ? r.ideas.filter(i => i.decision !== 'approved').length + r.choices.length : 0; if (tab === 'more' && !state.create && !state.chair) render(); }).catch(() => {}); } - if (what === 'director') { const [r, a] = await Promise.all([api('/api/director'), api('/api/arrivals').catch(() => ({arrivals: []}))]); state.director = r; state.arrivals = a.arrivals; } + if (what === 'director') { const [r, a, u] = await Promise.all([api('/api/director'), api('/api/arrivals').catch(() => ({arrivals: []})), api('/api/unplayable').catch(() => ({items: []}))]); + state.director = r; state.arrivals = a.arrivals; state.unplayable = u.items; } offline = false; } catch (e) { if (!offline) toast(e.message === 'Failed to fetch' ? "Orbit isn't open on the TV" : e.message); offline = true; } // Making a channel isn't redrawn by the background refresh, so typing is never lost. @@ -780,6 +784,7 @@ document.addEventListener('click', e => { if (d.kmake) { makeChannel(d.kmake); return; } if (d.kbrand !== undefined) { const c = state.create; c.draft.name = ($('#kname')?.value || c.draft.name || '').trim(); c.draft.brand = d.kbrand; render(); return; } if (d.create) { startCreate({name: '', description: '', style: 'Shaped', hours: null, shows: [], skipped: []}); return; } + if (d.uretry) { api('/api/unplayable/retry', {id: d.uretry}).then(r => { toast(r.message); state.unplayable = state.unplayable.filter(u => u.id !== d.uretry); render(); }).catch(e => toast(e.message)); return; } if (d.kaddmore) { const c = state.create; c.quick = false; c.view = 'shows'; c.note = ''; render(); scrollTo(0, 0); return; } if (d.kdrop) { const dr = state.create.draft; dr.shows = dr.shows.filter(x => x.id !== d.kdrop); dr.core = dr.core.filter(i => i !== d.kdrop); delete dr.slots[d.kdrop]; render(); return; } if (d.kpower) { const [n, on] = d.kpower.split(':'); diff --git a/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt b/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt index 7ff44149..6ab3fef3 100644 --- a/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt +++ b/android/app/src/main/java/tv/orbit/classic/ChannelScheduler.kt @@ -284,6 +284,8 @@ internal class ChannelScheduler(private val store: ScheduleStore, /** A file that wouldn't play. It stays in what's already planned, and is left out from here on. */ fun markFailed(userId: String, itemId: String) { store.saveFailed(userId, store.loadFailed(userId) + itemId) + // Why, for the Chair's "won't play" list. + Unplayable.take(itemId)?.let { (title, channel, reason) -> runCatching { store.unplayable().add(itemId, title, channel, reason, clock()) } } } /** Starts a channel that has no loop yet: reads its pool, then gives it a small fallback made from that pool. */ diff --git a/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt b/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt index e8961a66..502dece7 100644 --- a/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt +++ b/android/app/src/main/java/tv/orbit/classic/CreateChannel.kt @@ -1,5 +1,7 @@ package tv.orbit.classic +import org.json.JSONObject + import androidx.activity.compose.BackHandler import androidx.compose.foundation.Canvas import androidx.compose.foundation.background @@ -65,6 +67,10 @@ internal class ChannelMaker( val power: suspend (Int, Boolean) -> String = { _, _ -> "That channel can't be changed here." }, /** Brings back the channel removed a moment ago, as it was. */ val restore: suspend (Int) -> String = { "That channel can't be brought back." }, + /** Files that won't play here: id, title, channel, why, when. */ + val unplayable: suspend () -> List = { emptyList() }, + /** Gives one unplayable file another try: it comes off the list and is planned again. */ + val retryUnplayable: suspend (String) -> String = { "That can't be done here." }, /** New titles from a channel's collection: added to it, or set aside as seen. */ val arrivals: suspend (Int, List, Boolean) -> String = { _, _, _ -> "That can't be done here." }) diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt index 3e21584c..9883608d 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt @@ -641,6 +641,14 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea SmartChannels.firstOrNull { it.number == number }?.let { setSmartSchedule(it, true) } "${gone.name} is back on $number." }, + unplayable = { withContext(Dispatchers.IO) { + val reasons = scheduleStore.unplayable().all() + scheduleStore.loadFailed(active.accountId).map { id -> (reasons[id] ?: org.json.JSONObject().put("title", "A file Orbit couldn't play").put("reason", "Noted before Orbit kept reasons.")).put("id", id) } + } }, + retryUnplayable = { id -> withContext(Dispatchers.IO) { + scheduleStore.saveFailed(active.accountId, scheduleStore.loadFailed(active.accountId) - id); scheduleStore.unplayable().remove(id) + "It'll be tried again as the channel plans ahead. If it still won't play, it comes back here." + } }, arrivals = { number, ids, add -> val ch = CustomChannels.of(number) ?: return@ChannelMaker "That channel has gone." val seen = ch.seen + ids diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackDialog.kt b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackDialog.kt index 233914c0..51f6b7dc 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackDialog.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackDialog.kt @@ -230,6 +230,8 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl return } if (scheduled != null) { + Unplayable.note(plan.item.id, plan.item.title, scheduled.channel.number, + unplayableReason(error.errorCodeName, generateSequence(error.cause) { it.cause }.firstOrNull()?.message?.take(120))) onUnplayable?.invoke(plan.item.id) failure = "This programme won't play on this box. Orbit moves on at ${clock(scheduled.programme.endMs)}." ready = false @@ -252,6 +254,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl if (scheduled != null && video.isNotEmpty() && video.none { it.isSupported }) { android.util.Log.w("OrbitSchedule", "channel=${scheduled.channel.number} noVideoDecoder=${video.first().getTrackFormat(0).sampleMimeType}") player.stop(); ready = false + Unplayable.note(plan.item.id, plan.item.title, scheduled.channel.number, "This TV has no decoder for its picture (${video.first().getTrackFormat(0).sampleMimeType}).") onUnplayable?.invoke(plan.item.id) failure = "This programme won't play on this box. Orbit moves on at ${clock(scheduled.programme.endMs)}." return diff --git a/android/app/src/main/java/tv/orbit/classic/GuidePicture.kt b/android/app/src/main/java/tv/orbit/classic/GuidePicture.kt index 724f1a85..6d547e06 100644 --- a/android/app/src/main/java/tv/orbit/classic/GuidePicture.kt +++ b/android/app/src/main/java/tv/orbit/classic/GuidePicture.kt @@ -151,6 +151,7 @@ private fun GuideLivePlayer(session: EmbySampleSession, plan: EmbyPlaybackPlan, val video = tracks.groups.filter { it.type == androidx.media3.common.C.TRACK_TYPE_VIDEO } if (video.isNotEmpty() && video.none { it.isSupported }) { android.util.Log.w("OrbitSchedule", "picture channel=$channelNumber noVideoDecoder=${video.first().getTrackFormat(0).sampleMimeType}") + Unplayable.note(plan.item.id, plan.item.title, channelNumber, "This TV has no decoder for its picture (${video.first().getTrackFormat(0).sampleMimeType}).") onCantPlay(plan.item.id) } } diff --git a/android/app/src/main/java/tv/orbit/classic/Idents.kt b/android/app/src/main/java/tv/orbit/classic/Idents.kt index d3630193..46bcf78b 100644 --- a/android/app/src/main/java/tv/orbit/classic/Idents.kt +++ b/android/app/src/main/java/tv/orbit/classic/Idents.kt @@ -39,10 +39,9 @@ private val IdentVideos = mapOf(108 to R.raw.ident_108, 109 to R.raw.ident_109, /** [atMs] is when the next programme starts, for a channel whose ident follows the time of day. */ /** - * Idents with a sound of their own (Paul, 7 November 2026; design/channels/sound): played with Ident sound on, at most once - * every 20 minutes a channel, so a run of short programmes doesn't repeat it every few minutes. + * Every channel's ident has a sound of its own (Paul, 7 November 2026; design/channels/sound), played with Ident sound on, at + * most once every 20 minutes a channel, so a run of short programmes doesn't repeat it every few minutes. Tots keeps its jingle. */ -internal val IdentsWithSound = setOf(R.raw.ident_mistletoe, R.raw.ident_sakura, R.raw.ident_109, R.raw.ident_110) internal object IdentStings { private val last = HashMap() const val GAP_MS = 20 * 60_000L @@ -133,7 +132,7 @@ internal fun IdentOverlay(session: EmbySampleSession, channel: SampleChannel, ne seekTo(startedLateMs.coerceIn(0, identMs)) volume = if (block != null) (if (settings.blockIdentSound) 1f else 0f) else if (mood != null && settings.identSound && TotsJingle.take(mood, System.currentTimeMillis())) 1f - else if (mood == null && video in IdentsWithSound && settings.identSound && IdentStings.take(channel.number, System.currentTimeMillis())) 1f else 0f + else if (mood == null && settings.identSound && IdentStings.take(channel.number, System.currentTimeMillis())) 1f else 0f prepare(); playWhenReady = true } } diff --git a/android/app/src/main/java/tv/orbit/classic/InstallSnapshot.kt b/android/app/src/main/java/tv/orbit/classic/InstallSnapshot.kt index c1a11c5e..d55df810 100644 --- a/android/app/src/main/java/tv/orbit/classic/InstallSnapshot.kt +++ b/android/app/src/main/java/tv/orbit/classic/InstallSnapshot.kt @@ -38,6 +38,8 @@ internal object InstallSnapshot { val schedule = File(data, "no_backup/schedule") schedule.copyRecursively(File(out, "no_backup/schedule"), overwrite = true) File(data, "shared_prefs/orbit_settings.xml").takeIf { it.exists() }?.copyTo(File(out, "shared_prefs/orbit_settings.xml"), overwrite = true) + // Profiles too (7 November 2026), so an install can be shown to keep everyone; names and channels only, no PIN. + File(data, "shared_prefs/orbit_profiles.xml").takeIf { it.exists() }?.copyTo(File(out, "shared_prefs/orbit_profiles.xml"), overwrite = true) File(out, "hashes.txt").writeText(listOf("no_backup/catalogue.db", "no_backup/orbit-connection.v1") .joinToString("\n") { "${sha256(File(data, it))} $it" } + "\n") "copied ${schedule.walk().count { it.isFile }}" diff --git a/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt b/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt index 3f63eb71..741593c0 100644 --- a/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt +++ b/android/app/src/main/java/tv/orbit/classic/PhoneLink.kt @@ -408,6 +408,13 @@ internal object PhoneLink { val said = runBlocking { withContext(mainDispatcher) { h.maker.restore(number) } } json(out, 200, JSONObject().put("message", said)) } + // Files that won't play, with why (7 November 2026), for the Director's Chair on the phone; Try again takes one off. + "GET /api/unplayable" -> json(out, 200, JSONObject().put("items", JSONArray(runBlocking { h.maker.unplayable() }.take(50)))) + "POST /api/unplayable/retry" -> { + if (!OrbitCompanion.grownUp) return json(out, 403, JSONObject().put("error", "Kids is watching. Switch to Adult.")) + val id = runCatching { JSONObject(r.body).getString("id") }.getOrNull()?.takeIf(EmbyClient::validId) ?: return json(out, 400, JSONObject()) + json(out, 200, JSONObject().put("message", runBlocking { h.maker.retryUnplayable(id) })) + } // New in a channel's collection since you last looked, for the Director's Chair on the phone. "GET /api/arrivals" -> { val cols = runBlocking { h.maker.collections() }.associateBy { it.name } diff --git a/android/app/src/main/java/tv/orbit/classic/Rooms.kt b/android/app/src/main/java/tv/orbit/classic/Rooms.kt index dd36c4e9..1042d59a 100644 --- a/android/app/src/main/java/tv/orbit/classic/Rooms.kt +++ b/android/app/src/main/java/tv/orbit/classic/Rooms.kt @@ -62,7 +62,7 @@ internal object RoomCrypto { /** The parts of a set-up that can come across, each ticked on the new box before it's applied. */ internal enum class RoomPart(val title: String, val line: String) { Channels("Channels and your own channels", "Which channels are on, the channels you've made, and the titles chosen for them"), - Family("Profiles, Kids and the Adult PIN", "The PIN comes across scrambled, never as its digits"), + Family("Profiles, Kids and the Adult PIN", "Everyone's profile, what Orbit has learnt for each, and their Continue watching. The PIN comes across scrambled, never as its digits"), Look("Look and On screen settings", "The look, subtitles, the cast, motion and the rest"), Director("Director's Chair decisions", "What you placed, dropped and taught it"), Arcade("Arcade bests", "High scores and games won") @@ -77,6 +77,44 @@ private const val BUNDLE_LIMIT = 12 * 1024 * 1024 /** The files that make a room's schedules: plans, progress, the Drive-In's bookings and tickets, and what couldn't play. */ private val ScheduleFiles = Regex("(schedule|progress|booked|tickets|failed)-\\d+\\.json") +/** Each person's Continue watching, and their Taste files, that travel with Family. */ +private val FamilyFiles = Regex("continue-[A-Za-z0-9]{1,40}\\.json") +private val TasteFiles = Regex("[A-Za-z0-9_-]{1,40}\\.(events\\.jsonl|state\\.json)") + +/** Both rooms' profiles: the same id is the same person (the incoming details win); the result always has a grown-up. */ +internal fun mergedProfiles(here: List, incoming: List): List { + val byId = LinkedHashMap(); (here + incoming).forEach { byId[it.id] = it } + return byId.values.toList().take(MAX_PROFILES).takeIf { list -> list.any { it.kind == ProfileKind.Grown } } ?: incoming.ifEmpty { here } +} + +/** + * Taste and Continue watching from another room, merged into [dir]: Taste events joined by their ids (each counted once, kept in + * bounds), a profile's Taste settings kept as they are here when already set, and Continue watching keeping the latest place + * for each programme. + */ +internal fun mergeFamilyFiles(dir: File, files: JSONObject, nowMs: Long = System.currentTimeMillis()) { + files.keys().forEach { name -> + val text = files.getString(name) + when { + name.startsWith("taste/") && name.endsWith(".events.jsonl") && TasteFiles.matches(name.removePrefix("taste/")) -> { + val target = File(dir, name).also { it.parentFile?.mkdirs() } + val here = if (target.exists()) target.readLines().mapNotNull { TasteEvent.of(it) } else emptyList() + val merged = compactTaste(here + text.lines().mapNotNull { TasteEvent.of(it) }, nowMs) + target.writeText(merged.joinToString("") { it.toLine() + "\n" }) + } + name.startsWith("taste/") && name.endsWith(".state.json") && TasteFiles.matches(name.removePrefix("taste/")) -> + File(dir, name).let { if (!it.exists()) { it.parentFile?.mkdirs(); it.writeText(text) } } + FamilyFiles.matches(name) -> { + val target = File(dir, name) + fun marks(t: String) = runCatching { JSONArray(t).let { a -> (0 until a.length()).mapNotNull { runCatching { ContinueMark.fromJson(a.getJSONObject(it)) }.getOrNull() } } }.getOrDefault(emptyList()) + val all = (if (target.exists()) marks(target.readText()) else emptyList()) + marks(text) + val latest = all.groupBy { it.number to it.startMs }.values.map { same -> same.maxBy { it.atMs } }.sortedByDescending { it.atMs }.take(20) + target.writeText(JSONArray(latest.map { it.toJson() }).toString()) + } + } + } +} + /** What one box sends another: plain settings and small files, read from the open workspace. Never a password or token. */ internal object RoomBundle { private fun prefsJson(context: Context, name: String, keys: List?): JSONObject { @@ -119,7 +157,10 @@ internal object RoomBundle { // Same schedules as this room, if the new one chooses: the plans, where each channel is up to, and the Drive-In's // bookings and tickets, copied once, so the same programme is on in both rooms. .put("schedules", gzip(files(dir, dir.list().orEmpty().filter { ScheduleFiles.matches(it) }.sorted()).toString())) - .put(RoomPart.Family.name, JSONObject().put("profiles", prefsJson(context, "orbit_profiles", null)).put("lock", prefsJson(context, "orbit_lock", listOf("after_dark_salt", "after_dark_pin")))) + .put(RoomPart.Family.name, JSONObject().put("profiles", prefsJson(context, "orbit_profiles", null)).put("lock", prefsJson(context, "orbit_lock", listOf("after_dark_salt", "after_dark_pin"))) + // Each person's Taste and Continue watching (Rooms sync, 7 November 2026): merged on arrival, never overwriting. + .put("people", gzip(files(dir, dir.list().orEmpty().filter { FamilyFiles.matches(it) }.sorted() + + File(dir, "taste").list().orEmpty().filter { TasteFiles.matches(it) }.sorted().map { "taste/$it" }).toString()))) .put(RoomPart.Look.name, prefsJson(context, "orbit_settings", LookKeys)) .put(RoomPart.Director.name, files(dir, DirectorFiles)) .put(RoomPart.Arcade.name, prefsJson(context, "orbit_settings", ArcadeKeys)) @@ -130,7 +171,12 @@ internal object RoomBundle { if (RoomPart.Look in parts) { putPrefs(context, "orbit_settings", bundle.optJSONObject(RoomPart.Look.name), LookKeys); OrbitTheme.load(context) } if (RoomPart.Arcade in parts) putPrefs(context, "orbit_settings", bundle.optJSONObject(RoomPart.Arcade.name), ArcadeKeys) if (RoomPart.Family in parts) bundle.optJSONObject(RoomPart.Family.name)?.let { f -> - putPrefs(context, "orbit_profiles", f.optJSONObject("profiles"), listOf("profiles", "kids_on")) + // Everyone from both rooms: the same profile id is the same person, the sender's details winning. + val incoming = runCatching { f.getJSONObject("profiles").getJSONObject("profiles").getString("v") }.getOrNull() + val here = context.getSharedPreferences("orbit_profiles", Context.MODE_PRIVATE).getString("profiles", null) + putPrefs(context, "orbit_profiles", f.optJSONObject("profiles"), listOf("kids_on")) + if (incoming != null) runCatching { mergedProfiles(here?.let { Profiles.decode(it) }.orEmpty(), Profiles.decode(incoming)) }.getOrNull()?.let { merged -> + context.getSharedPreferences("orbit_profiles", Context.MODE_PRIVATE).edit().putString("profiles", Profiles.encode(merged)).apply() } putPrefs(context, "orbit_lock", f.optJSONObject("lock"), listOf("after_dark_salt", "after_dark_pin")) AfterDarkLock.load(context); Profiles.load(context) } @@ -150,6 +196,8 @@ internal object RoomBundle { lineup = c.optJSONArray("lineup")?.let { a -> (0 until minOf(a.length(), 200)).map { a.getInt(it) } }.orEmpty() } if (RoomPart.Director in parts) write(bundle.optJSONObject(RoomPart.Director.name)) + if (RoomPart.Family in parts) bundle.optJSONObject(RoomPart.Family.name)?.optString("people")?.takeIf { it.isNotBlank() }?.let { packed -> + runCatching { mergeFamilyFiles(dir, JSONObject(gunzip(packed))) } } // Only with the channels: a schedule is for a channel that's on. Never over a schedule this box already has. if (sameSchedules && RoomPart.Channels in parts) bundle.optString("schedules").takeIf { it.isNotBlank() }?.let { packed -> runCatching { JSONObject(gunzip(packed)).let { files -> files.keys().forEach { n -> diff --git a/android/app/src/main/java/tv/orbit/classic/ScheduleStore.kt b/android/app/src/main/java/tv/orbit/classic/ScheduleStore.kt index 3631fea4..1747134f 100644 --- a/android/app/src/main/java/tv/orbit/classic/ScheduleStore.kt +++ b/android/app/src/main/java/tv/orbit/classic/ScheduleStore.kt @@ -166,6 +166,7 @@ internal class ScheduleStore(private val directory: File) { } /** Files that wouldn't play on this box, across every channel. Never planned again. */ + fun unplayable() = UnplayableLog(File(directory, "failed-reasons-0.json")) fun saveFailed(userId: String, ids: Set) = write(file("failed", 0), root(userId, 0).put("items", JSONArray(ids.toList()))) /** diff --git a/android/app/src/main/java/tv/orbit/classic/Settings.kt b/android/app/src/main/java/tv/orbit/classic/Settings.kt index 289b2d72..13c7857e 100644 --- a/android/app/src/main/java/tv/orbit/classic/Settings.kt +++ b/android/app/src/main/java/tv/orbit/classic/Settings.kt @@ -35,6 +35,8 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogProperties import androidx.tv.material3.Text import kotlinx.coroutines.launch @@ -279,7 +281,7 @@ private fun ViewingDetail(firstSwitch: FocusRequester, modifier: Modifier, top: SettingLine("Idents", "Play each channel's ident between programmes. When off, Tots shows a still picture instead.") { OnOff(idents, Modifier, onClick = { idents = !idents; settings.idents = idents }) } - SettingLine("Ident sound", "Let Tots play its jingle, and channels with a sound of their own (Mistletoe, Sakura, Signature, Unscripted) play theirs, never too often.") { + SettingLine("Ident sound", "Each channel's ident plays its own short sound, at most every 20 minutes a channel; Tots plays its jingle.") { OnOff(identSound, Modifier, onClick = { identSound = !identSound; settings.identSound = identSound }) } SettingLine("Special idents", "Give named blocks and events their own ident as they begin, such as Riot Laughs or PPV Sunday. Off uses each channel's usual ident.") { @@ -350,7 +352,25 @@ private fun RoomsDetail(firstSwitch: FocusRequester, modifier: Modifier) { var adding by remember { mutableStateOf(false) } var naming by remember { mutableStateOf(false) } var connecting by remember { mutableStateOf(false) } + var bringing by remember { mutableStateOf(false) } + var brought by remember { mutableStateOf(null) } if (adding) { AddRoomPanel(onClose = { adding = false }, modifier = modifier); return } + // Rooms sync (Paul, 7 November 2026): a TV already set up can bring in another room's family, Taste and Continue watching. + // What's ticked is merged: people join, events join by id, nothing here is overwritten, and no schedule or channel changes. + if (bringing) { + Dialog(onDismissRequest = { bringing = false }, properties = DialogProperties(usePlatformDefaultWidth = false)) { + Box(Modifier.fillMaxSize().background(Navy)) { + JoinRoomFlow(onJoined = { + RoomArrival.bundle?.let { got -> + runCatching { RoomBundle.applyToWorkspace(Workspaces.current(context).scheduleDir, got, RoomArrival.parts - RoomPart.Channels, sameSchedules = false) } + brought = "Brought in from ${got.optString("room").ifBlank { "the other room" }}." + } + RoomArrival.done(); bringing = false + }, onBack = { RoomArrival.done(); bringing = false }) + } + } + return + } if (connecting) { // Orbit Companion (Paul, 6 November 2026): the same one-time code as Create your own's, from where phones are listed. BackHandler { connecting = false } @@ -372,6 +392,9 @@ private fun RoomsDetail(firstSwitch: FocusRequester, modifier: Modifier) { listOf("Living Room", "Lounge", "Bedroom", "Kids' room", "Kitchen", "Den").forEach { n -> OrbitButton(n, selected = n == Rooms.name, onClick = { Rooms.rename(context, n); naming = false }) } } Heading("Other rooms") + SettingLine("Bring in from another room", brought ?: "Everyone's profiles, what Orbit has learnt for each, and their Continue watching, merged in from a TV that's already set up. Channels and schedules here stay as they are.") { + OrbitButton("Bring in", onClick = { bringing = true }) + } SettingLine("Add a room", "Set up Orbit on another TV in your home by copying this one: channels, profiles, look and more. Your password never travels.") { OrbitButton("Add a room", onClick = { adding = true }) } diff --git a/android/app/src/main/java/tv/orbit/classic/Unplayable.kt b/android/app/src/main/java/tv/orbit/classic/Unplayable.kt new file mode 100644 index 00000000..c9617a13 --- /dev/null +++ b/android/app/src/main/java/tv/orbit/classic/Unplayable.kt @@ -0,0 +1,41 @@ +package tv.orbit.classic + +import org.json.JSONObject +import java.io.File + +/** + * Files that won't play, with why (Paul, 7 November 2026: The Twilight Zone S1 E3 failed and nobody knew). The player notes the + * reason as it gives up on a file; the list beside the failed list keeps it, with the title and channel, so the phone's Director's + * Chair can show each one and offer Try again. Only names, channels and the player's own error kinds are kept. + */ +internal object Unplayable { + private val pending = HashMap>() + /** Noted by the player just before it reports [itemId] as unplayable. */ + @Synchronized fun note(itemId: String, title: String, channel: Int?, reason: String) { pending[itemId] = Triple(title, channel, reason) } + @Synchronized fun take(itemId: String) = pending.remove(itemId) +} + +/** The player's error kind, in a sentence someone can act on. */ +internal fun unplayableReason(errorCodeName: String?, detail: String? = null): String = when { + errorCodeName == null && detail != null -> detail + errorCodeName == null -> "It stopped without saying why." + "PARSING" in errorCodeName -> "The file's structure couldn't be read (${detail ?: errorCodeName})." + "DECODER" in errorCodeName || "DECODING" in errorCodeName -> "This TV can't decode its picture or sound." + "IO_" in errorCodeName -> "The file couldn't be fetched from the server." + "AUDIO_TRACK" in errorCodeName -> "Its sound couldn't be played on this TV." + else -> "The player stopped ($errorCodeName)." +} + +/** The reasons file: one entry per failed item, `{title, channel, reason, at}`. */ +internal class UnplayableLog(private val file: File) { + @Synchronized fun all(): Map = runCatching { JSONObject(file.readText()).let { o -> o.keys().asSequence().associateWith { o.getJSONObject(it) } } }.getOrDefault(emptyMap()) + @Synchronized fun add(itemId: String, title: String, channel: Int?, reason: String, nowMs: Long) { + val o = runCatching { JSONObject(file.readText()) }.getOrDefault(JSONObject()) + o.put(itemId, JSONObject().put("title", title.take(160)).put("channel", channel ?: JSONObject.NULL).put("reason", reason.take(240)).put("at", nowMs)) + file.writeText(o.toString()) + } + @Synchronized fun remove(itemId: String) { + val o = runCatching { JSONObject(file.readText()) }.getOrNull() ?: return + o.remove(itemId); file.writeText(o.toString()) + } +} diff --git a/android/app/src/main/res/raw/ident_101.mp4 b/android/app/src/main/res/raw/ident_101.mp4 index 164b63e0..991cd071 100644 Binary files a/android/app/src/main/res/raw/ident_101.mp4 and b/android/app/src/main/res/raw/ident_101.mp4 differ diff --git a/android/app/src/main/res/raw/ident_102.mp4 b/android/app/src/main/res/raw/ident_102.mp4 index 66395876..058bc77d 100644 Binary files a/android/app/src/main/res/raw/ident_102.mp4 and b/android/app/src/main/res/raw/ident_102.mp4 differ diff --git a/android/app/src/main/res/raw/ident_103.mp4 b/android/app/src/main/res/raw/ident_103.mp4 index bf0c8e34..6a79c782 100644 Binary files a/android/app/src/main/res/raw/ident_103.mp4 and b/android/app/src/main/res/raw/ident_103.mp4 differ diff --git a/android/app/src/main/res/raw/ident_104.mp4 b/android/app/src/main/res/raw/ident_104.mp4 index b34f79e2..ac0c3d10 100644 Binary files a/android/app/src/main/res/raw/ident_104.mp4 and b/android/app/src/main/res/raw/ident_104.mp4 differ diff --git a/android/app/src/main/res/raw/ident_105.mp4 b/android/app/src/main/res/raw/ident_105.mp4 index b3a7c092..50478ab7 100644 Binary files a/android/app/src/main/res/raw/ident_105.mp4 and b/android/app/src/main/res/raw/ident_105.mp4 differ diff --git a/android/app/src/main/res/raw/ident_106.mp4 b/android/app/src/main/res/raw/ident_106.mp4 index 591c6af7..2e62a88c 100644 Binary files a/android/app/src/main/res/raw/ident_106.mp4 and b/android/app/src/main/res/raw/ident_106.mp4 differ diff --git a/android/app/src/main/res/raw/ident_107.mp4 b/android/app/src/main/res/raw/ident_107.mp4 index cdd9d9da..7ff871dd 100644 Binary files a/android/app/src/main/res/raw/ident_107.mp4 and b/android/app/src/main/res/raw/ident_107.mp4 differ diff --git a/android/app/src/main/res/raw/ident_108.mp4 b/android/app/src/main/res/raw/ident_108.mp4 index ed33b6da..3c4433c4 100644 Binary files a/android/app/src/main/res/raw/ident_108.mp4 and b/android/app/src/main/res/raw/ident_108.mp4 differ diff --git a/android/app/src/main/res/raw/ident_201.mp4 b/android/app/src/main/res/raw/ident_201.mp4 index 69a8fd53..10da3689 100644 Binary files a/android/app/src/main/res/raw/ident_201.mp4 and b/android/app/src/main/res/raw/ident_201.mp4 differ diff --git a/android/app/src/main/res/raw/ident_202.mp4 b/android/app/src/main/res/raw/ident_202.mp4 index 3cc99d40..ddea2367 100644 Binary files a/android/app/src/main/res/raw/ident_202.mp4 and b/android/app/src/main/res/raw/ident_202.mp4 differ diff --git a/android/app/src/main/res/raw/ident_203.mp4 b/android/app/src/main/res/raw/ident_203.mp4 index d37dec2d..0222f52c 100644 Binary files a/android/app/src/main/res/raw/ident_203.mp4 and b/android/app/src/main/res/raw/ident_203.mp4 differ diff --git a/android/app/src/main/res/raw/ident_204.mp4 b/android/app/src/main/res/raw/ident_204.mp4 index f6d6fd3e..04a2c388 100644 Binary files a/android/app/src/main/res/raw/ident_204.mp4 and b/android/app/src/main/res/raw/ident_204.mp4 differ diff --git a/android/app/src/main/res/raw/ident_205.mp4 b/android/app/src/main/res/raw/ident_205.mp4 index 831e75a3..95f37911 100644 Binary files a/android/app/src/main/res/raw/ident_205.mp4 and b/android/app/src/main/res/raw/ident_205.mp4 differ diff --git a/android/app/src/main/res/raw/ident_206.mp4 b/android/app/src/main/res/raw/ident_206.mp4 index a84e7863..cfc016b3 100644 Binary files a/android/app/src/main/res/raw/ident_206.mp4 and b/android/app/src/main/res/raw/ident_206.mp4 differ diff --git a/android/app/src/main/res/raw/ident_301.mp4 b/android/app/src/main/res/raw/ident_301.mp4 index 828bcd25..f95e884f 100644 Binary files a/android/app/src/main/res/raw/ident_301.mp4 and b/android/app/src/main/res/raw/ident_301.mp4 differ diff --git a/android/app/src/main/res/raw/ident_302.mp4 b/android/app/src/main/res/raw/ident_302.mp4 index b2dd8a87..70c0f2f1 100644 Binary files a/android/app/src/main/res/raw/ident_302.mp4 and b/android/app/src/main/res/raw/ident_302.mp4 differ diff --git a/android/app/src/main/res/raw/ident_303.mp4 b/android/app/src/main/res/raw/ident_303.mp4 index 739894f4..417a68c1 100644 Binary files a/android/app/src/main/res/raw/ident_303.mp4 and b/android/app/src/main/res/raw/ident_303.mp4 differ diff --git a/android/app/src/main/res/raw/ident_304.mp4 b/android/app/src/main/res/raw/ident_304.mp4 index d884d296..d1817e7a 100644 Binary files a/android/app/src/main/res/raw/ident_304.mp4 and b/android/app/src/main/res/raw/ident_304.mp4 differ diff --git a/android/app/src/main/res/raw/ident_305.mp4 b/android/app/src/main/res/raw/ident_305.mp4 index 9eac1209..4adf817d 100644 Binary files a/android/app/src/main/res/raw/ident_305.mp4 and b/android/app/src/main/res/raw/ident_305.mp4 differ diff --git a/android/app/src/main/res/raw/ident_306.mp4 b/android/app/src/main/res/raw/ident_306.mp4 index 13eb13a0..7dea0d28 100644 Binary files a/android/app/src/main/res/raw/ident_306.mp4 and b/android/app/src/main/res/raw/ident_306.mp4 differ diff --git a/android/app/src/main/res/raw/ident_307.mp4 b/android/app/src/main/res/raw/ident_307.mp4 index 1e258747..b1a82586 100644 Binary files a/android/app/src/main/res/raw/ident_307.mp4 and b/android/app/src/main/res/raw/ident_307.mp4 differ diff --git a/android/app/src/main/res/raw/ident_308.mp4 b/android/app/src/main/res/raw/ident_308.mp4 index 550e5c02..263398fb 100644 Binary files a/android/app/src/main/res/raw/ident_308.mp4 and b/android/app/src/main/res/raw/ident_308.mp4 differ diff --git a/android/app/src/main/res/raw/ident_309.mp4 b/android/app/src/main/res/raw/ident_309.mp4 index e0b3ee49..4827b6e4 100644 Binary files a/android/app/src/main/res/raw/ident_309.mp4 and b/android/app/src/main/res/raw/ident_309.mp4 differ diff --git a/android/app/src/main/res/raw/ident_310.mp4 b/android/app/src/main/res/raw/ident_310.mp4 index 34a8d0de..fc4c3235 100644 Binary files a/android/app/src/main/res/raw/ident_310.mp4 and b/android/app/src/main/res/raw/ident_310.mp4 differ diff --git a/android/app/src/main/res/raw/ident_401.mp4 b/android/app/src/main/res/raw/ident_401.mp4 index d3985adf..cb09cb42 100644 Binary files a/android/app/src/main/res/raw/ident_401.mp4 and b/android/app/src/main/res/raw/ident_401.mp4 differ diff --git a/android/app/src/main/res/raw/ident_601.mp4 b/android/app/src/main/res/raw/ident_601.mp4 index e7f42a82..4503398a 100644 Binary files a/android/app/src/main/res/raw/ident_601.mp4 and b/android/app/src/main/res/raw/ident_601.mp4 differ diff --git a/android/app/src/main/res/raw/ident_602.mp4 b/android/app/src/main/res/raw/ident_602.mp4 index 129b3316..553f406c 100644 Binary files a/android/app/src/main/res/raw/ident_602.mp4 and b/android/app/src/main/res/raw/ident_602.mp4 differ diff --git a/android/app/src/main/res/raw/ident_603.mp4 b/android/app/src/main/res/raw/ident_603.mp4 index 9b62a06a..51641f48 100644 Binary files a/android/app/src/main/res/raw/ident_603.mp4 and b/android/app/src/main/res/raw/ident_603.mp4 differ diff --git a/android/app/src/main/res/raw/ident_604.mp4 b/android/app/src/main/res/raw/ident_604.mp4 index ab1726b1..47ae90e3 100644 Binary files a/android/app/src/main/res/raw/ident_604.mp4 and b/android/app/src/main/res/raw/ident_604.mp4 differ diff --git a/android/app/src/main/res/raw/ident_605.mp4 b/android/app/src/main/res/raw/ident_605.mp4 index 30e233cf..e3e8fb2b 100644 Binary files a/android/app/src/main/res/raw/ident_605.mp4 and b/android/app/src/main/res/raw/ident_605.mp4 differ diff --git a/android/app/src/main/res/raw/ident_611.mp4 b/android/app/src/main/res/raw/ident_611.mp4 index 27a0623f..fa1b15fb 100644 Binary files a/android/app/src/main/res/raw/ident_611.mp4 and b/android/app/src/main/res/raw/ident_611.mp4 differ diff --git a/android/app/src/main/res/raw/ident_612.mp4 b/android/app/src/main/res/raw/ident_612.mp4 index 8aa3efe5..9baafbf7 100644 Binary files a/android/app/src/main/res/raw/ident_612.mp4 and b/android/app/src/main/res/raw/ident_612.mp4 differ diff --git a/android/app/src/main/res/raw/ident_613.mp4 b/android/app/src/main/res/raw/ident_613.mp4 index 00edaec4..99c6b6d2 100644 Binary files a/android/app/src/main/res/raw/ident_613.mp4 and b/android/app/src/main/res/raw/ident_613.mp4 differ diff --git a/android/app/src/test/java/tv/orbit/classic/RoomsFamilyTest.kt b/android/app/src/test/java/tv/orbit/classic/RoomsFamilyTest.kt new file mode 100644 index 00000000..a913e2d2 --- /dev/null +++ b/android/app/src/test/java/tv/orbit/classic/RoomsFamilyTest.kt @@ -0,0 +1,54 @@ +package tv.orbit.classic + +import org.json.JSONArray +import org.json.JSONObject +import org.junit.Assert.* +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +/** Rooms sync (7 November 2026): profiles, Taste and Continue watching merge between rooms, never overwriting or doubling. */ +class RoomsFamilyTest { + @get:Rule val tmp = TemporaryFolder() + + @Test fun profilesFromBothRoomsJoin() { + val wife = Profile("pwife01", "Wife", "sil-pink", ProfileKind.Grown) + val renamed = DefaultProfiles.first().copy(name = "Paul") + val merged = mergedProfiles(DefaultProfiles, listOf(renamed, DefaultProfiles[1], wife)) + assertEquals(listOf("grown", "kids", "pwife01"), merged.map { it.id }) + assertEquals("Paul", merged.first().name) + } + + @Test fun tasteAndContinueWatchingMergeByIdAndLatest() { + val dir = tmp.newFolder("schedule") + val now = 1_794_000_000_000L + fun ev(id: String, item: String, at: Long) = TasteEvent(id, "grown", TasteKind.Chose, item, null, "T", 106, at, null, "test") + java.io.File(dir, "taste").mkdirs() + java.io.File(dir, "taste/grown.events.jsonl").writeText(ev("a", "1001", now - 5_000).toLine() + "\n") + java.io.File(dir, "taste/grown.state.json").writeText(TasteState(false).toJson().toString()) + java.io.File(dir, "continue-grown.json").writeText(JSONArray(listOf(ContinueMark(106, 10, "1001", 60_000, 2_700_000, now - 9_000).toJson())).toString()) + val incoming = JSONObject() + .put("taste/grown.events.jsonl", ev("a", "1001", now - 5_000).toLine() + "\n" + ev("b", "1002", now - 1_000).toLine() + "\n") + .put("taste/grown.state.json", TasteState(true).toJson().toString()) + .put("taste/pwife01.events.jsonl", TasteEvent("c", "pwife01", TasteKind.Saved, "2001", null, "W", 205, now, null, "test").toLine() + "\n") + .put("continue-grown.json", JSONArray(listOf(ContinueMark(106, 10, "1001", 900_000, 2_700_000, now - 1_000).toJson())).toString()) + .put("../evil.json", "x") + mergeFamilyFiles(dir, incoming, now) + val events = java.io.File(dir, "taste/grown.events.jsonl").readLines().mapNotNull { TasteEvent.of(it) } + assertEquals(listOf("a", "b"), events.map { it.id }) + assertFalse("this room's own Personalise choice stays", JSONObject(java.io.File(dir, "taste/grown.state.json").readText()).getBoolean("personalise")) + assertTrue(java.io.File(dir, "taste/pwife01.events.jsonl").exists()) + val marks = JSONArray(java.io.File(dir, "continue-grown.json").readText()) + assertEquals(1, marks.length()); assertEquals(900_000L, marks.getJSONObject(0).getLong("p")) + assertFalse(java.io.File(tmp.root, "evil.json").exists()) + } + + @Test fun unplayableReasonsReadPlainly() { + assertTrue(unplayableReason("ERROR_CODE_PARSING_CONTAINER_MALFORMED", "ContentCompAlgo 0").startsWith("The file's structure")) + assertEquals("This TV can't decode its picture or sound.", unplayableReason("ERROR_CODE_DECODER_INIT_FAILED")) + val log = UnplayableLog(java.io.File(tmp.root, "failed-reasons-0.json")) + log.add("7542928", "The Twilight Zone / S1 E3", 106, "x", 1); log.add("1", "Other", null, "y", 2) + log.remove("1") + assertEquals(setOf("7542928"), log.all().keys) + } +} diff --git a/design/channels/sound/build-ident-stings.py b/design/channels/sound/build-ident-stings.py index adc2dff3..0d03ceae 100644 --- a/design/channels/sound/build-ident-stings.py +++ b/design/channels/sound/build-ident-stings.py @@ -190,6 +190,150 @@ def unscripted(): return fade_out(reverb(b, .2, .9)) + + + +# ---- Every other channel (Paul, 7 November 2026: "sound for the remaining idents") ---------------------------------------- +# One family of sound per kind of channel, each channel its own key and motif, so they sound related but never the same. + +MAJOR = [0, 2, 4, 7, 9, 12, 14, 16] +MINOR = [0, 3, 7, 10, 12, 15, 19] + + +def hz(root, semis): + return root * 2 ** (semis / 12) + + +def fam_bright(seed, root): + """Entertainment: a piano-bell arpeggio rising into a warm major chord.""" + random.seed(seed); b = blank() + steps = random.sample(MAJOR[:6], 4); steps.sort() + for k, s in enumerate(steps): + add_bell(b, 1.2 + k * .16, hz(root * 2, s), .3, 1.8, ((1, 1), (2, .4), (3, .18), (4.02, .08))) + add_pad(b, 1.0, 5.4, [hz(root, s) for s in (0, 7, 16, 23)], .45, attack=1.0) + add_bell(b, 2.9, hz(root * 4, steps[-1]), .14, 2.0) + return fade_out(reverb(b, .28, 1.1)) + + +def fam_mystery(seed, root): + """Mystery and crime: a low thud, a minor cluster creeping in, a cold bell with a tritone under it.""" + random.seed(seed); b = blank() + add_thump(b, .5, .5, 70, 35, .8) + add_pad(b, .6, 5.5, [hz(root / 2, s) for s in (0, 3, 7, 13)], .5, attack=2.2, harmonics=(1, .25, .1), detune=.006) + add_bell(b, 2.8, hz(root * 2, 0), .22, 2.6); add_bell(b, 2.8, hz(root * 2, 6), .1, 2.4) + return fade_out(reverb(b, .38, 1.4)) + + +def fam_nature(seed, root): + """Nature and the world: marimba rolling a pentatonic phrase over an open, airy fifth.""" + random.seed(seed); b = blank() + phrase = [0, 2, 4, 7, 9, 12, 9, 14] + for k, s in enumerate(phrase[: random.choice((5, 6, 7))]): + add_bell(b, .9 + k * .17, hz(root * 2, s), .3, .55, ((1, 1), (3.99, .3), (10.1, .06))) + add_pad(b, .8, 5.6, [hz(root / 2, 0), hz(root / 2, 7), hz(root, 14)], .42, attack=1.6, harmonics=(1, .18)) + add_bell(b, 2.9, hz(root * 4, 7), .12, 2.4) + return fade_out(reverb(b, .32, 1.3)) + + +def fam_kitchen(seed, root): + """Food and home: a bright ukulele-ish strum and a friendly two-note button.""" + random.seed(seed); b = blank() + for t in (.6, 1.0, 1.4, 1.65): + for k, s in enumerate((0, 4, 7, 12)): + add_pluck(b, t + k * .012, hz(root * 2, s), .22, .993, .65) + add_clap(b, 2.0, .2) + add_bell(b, 2.6, hz(root * 4, 4), .2, .9); add_bell(b, 2.85, hz(root * 4, 12), .22, 1.4) + return fade_out(reverb(b, .22, .9)) + + +def fam_cinema(seed, root, minor=False, pulses=False, glide=False, wobble=False): + """Films: a swell into a brass-like chord and a timpani hit, with a flavour for each channel.""" + random.seed(seed); b = blank() + chord = (0, 3, 7, 12) if minor else (0, 4, 7, 12) + add_pad(b, .3, 5.2, [hz(root / 2, s) for s in chord], .55, attack=2.4, harmonics=(1, .6, .4, .28, .18, .1), detune=.008 if wobble else .003) + if pulses: + for k in range(10): add_thump(b, .3 + k * .25, .22 + k * .02, 80, 50, .12) + if glide: + s0 = int(.6 * SR) + for i in range(int(2.2 * SR)): + t = i / SR; f = hz(root * 4, 0) * (1.6 - .6 * min(1, t / 2.2)) + b[s0 + i] += .08 * math.sin(2 * math.pi * f * t) * math.sin(math.pi * t / 2.2) + add_thump(b, 2.8, .7, 120, 48, .6) + add_bell(b, 2.8, hz(root * 2, chord[2]), .14, 1.6, ((1, 1), (2, .5), (3, .3))) + return fade_out(reverb(b, .3, 1.3)) + + +def fam_horror(seed, root): + """Horror: a low drone, a creeping minor-second cluster and one high, glassy note.""" + random.seed(seed); b = blank() + add_pad(b, .2, 5.6, [hz(root / 4, 0), hz(root / 2, 1), hz(root / 2, 6)], .55, attack=2.6, harmonics=(1, .3, .15), detune=.01) + add_bell(b, 2.9, hz(root * 8, 1), .1, 3.0, ((1, 1), (2.01, .2))) + add_thump(b, 2.9, .5, 60, 30, 1.0) + return fade_out(reverb(b, .45, 1.5)) + + +def fam_romance(seed, root): + """Romance: a gentle piano phrase over strings.""" + random.seed(seed); b = blank() + for k, s in enumerate((7, 4, 9, 7, 12)): + add_bell(b, .8 + k * .3, hz(root * 2, s), .24, 2.2, ((1, 1), (2, .3), (3, .12))) + add_pad(b, .8, 5.6, [hz(root, s) for s in (0, 4, 7, 11)], .45, attack=1.8, harmonics=(1, .4, .2)) + return fade_out(reverb(b, .35, 1.3)) + + +def fam_christmas(seed, root): + """Christmas: sleigh bells and a celesta tune.""" + random.seed(seed); b = blank() + add_sleigh(b, .1, 3.0, .08) + for k, s in enumerate((7, 7, 9, 7, 12, 11)): + add_bell(b, .9 + k * .22, hz(root * 2, s), .26, 1.2) + add_pad(b, 1.2, 5.6, [hz(root / 2, s) for s in (0, 7, 16)], .4, attack=1.2) + return fade_out(reverb(b, .3, 1.1)) + + +def fam_sport(seed, root): + """Sport: drum hits building to a bright stab.""" + random.seed(seed); b = blank() + for k, t in enumerate((.4, .7, 1.0, 1.15, 1.3, 1.45, 1.6, 1.75)): + add_thump(b, t, .4 + k * .04, 110, 50, .15) + add_clap(b, 1.9, .3) + for s in (0, 4, 7, 12): add_bell(b, 2.0, hz(root, s), .16, .8, ((1, 1), (2, .6), (3, .4), (4, .3), (5, .2))) + add_thump(b, 2.0, .7, 100, 40, .5) + return fade_out(reverb(b, .2, .9)) + + +def fam_kids(seed, root): + """Kids: a bouncy xylophone tune and a springy boing.""" + random.seed(seed); b = blank() + tune = random.choice([(0, 4, 7, 12, 7, 12), (0, 2, 4, 7, 4, 12), (7, 4, 0, 4, 7, 12)]) + for k, s in enumerate(tune): + add_bell(b, .7 + k * .18, hz(root * 2, s), .3, .35, ((1, 1), (3.93, .35), (9.2, .1))) + s0 = int(2.0 * SR) + for i in range(int(.6 * SR)): + t = i / SR; f = 180 + 260 * math.exp(-t / .12) + 18 * math.sin(2 * math.pi * 14 * t) + b[s0 + i] += .18 * math.exp(-t / .25) * math.sin(2 * math.pi * f * t) + add_bell(b, 2.6, hz(root * 4, 0), .18, 1.2, ((1, 1), (3.93, .3))) + return fade_out(reverb(b, .2, .9)) + + +C3 = note("C3") +CHANNELS = { + 101: (fam_bright, 0), 102: (fam_bright, 5), 103: (fam_romance, 1), 104: (fam_bright, 3), 105: (fam_kitchen, 7), 106: (fam_mystery, 9), + 107: (fam_mystery, 2), 108: (fam_bright, 7), 201: (fam_nature, 2), 202: (fam_nature, 5), 203: (fam_nature, 7), 204: (fam_mystery, 4), + 205: (fam_kitchen, 0), 206: (fam_kitchen, 5), 301: (lambda s, r: fam_cinema(s, r), 0), 302: (lambda s, r: fam_cinema(s, r, minor=True, pulses=True), 2), + 303: (lambda s, r: fam_cinema(s, r, glide=True), 7), 304: (fam_horror, 1), 305: (lambda s, r: fam_cinema(s, r, minor=True), 5), + 306: (lambda s, r: fam_cinema(s, r, wobble=True), 3), 307: (fam_romance, 5), 308: (lambda s, r: fam_cinema(s, r, pulses=True), 9), + 309: (lambda s, r: fam_cinema(s, r), 10), 310: (fam_christmas, 0), 401: (fam_sport, 2), 601: (lambda s, r: fam_cinema(s, r, glide=True, minor=True), 9), + 602: (fam_kids, 2), 603: (fam_kids, 7), 604: (fam_kids, 5), 605: (fam_kids, 0), 611: (fam_kids, 4), 612: (fam_kids, 9), 613: (fam_kids, 11), +} + + +def build_channels(): + for number, (family, key) in CHANNELS.items(): + write(f"ch{number}", family(number, hz(C3, key))); print("wrote", number) + + if __name__ == "__main__": for name, make in (("mistletoe", mistletoe), ("sakura", sakura), ("signature", signature), ("unscripted", unscripted)): write(name, make()); print("wrote", name) + build_channels() diff --git a/design/channels/sound/out/ch101.wav b/design/channels/sound/out/ch101.wav new file mode 100644 index 00000000..aba47605 Binary files /dev/null and b/design/channels/sound/out/ch101.wav differ diff --git a/design/channels/sound/out/ch102.wav b/design/channels/sound/out/ch102.wav new file mode 100644 index 00000000..f73a616d Binary files /dev/null and b/design/channels/sound/out/ch102.wav differ diff --git a/design/channels/sound/out/ch103.wav b/design/channels/sound/out/ch103.wav new file mode 100644 index 00000000..0ef03858 Binary files /dev/null and b/design/channels/sound/out/ch103.wav differ diff --git a/design/channels/sound/out/ch104.wav b/design/channels/sound/out/ch104.wav new file mode 100644 index 00000000..165602cf Binary files /dev/null and b/design/channels/sound/out/ch104.wav differ diff --git a/design/channels/sound/out/ch105.wav b/design/channels/sound/out/ch105.wav new file mode 100644 index 00000000..50484b2b Binary files /dev/null and b/design/channels/sound/out/ch105.wav differ diff --git a/design/channels/sound/out/ch106.wav b/design/channels/sound/out/ch106.wav new file mode 100644 index 00000000..81d1e2fe Binary files /dev/null and b/design/channels/sound/out/ch106.wav differ diff --git a/design/channels/sound/out/ch107.wav b/design/channels/sound/out/ch107.wav new file mode 100644 index 00000000..a248a364 Binary files /dev/null and b/design/channels/sound/out/ch107.wav differ diff --git a/design/channels/sound/out/ch108.wav b/design/channels/sound/out/ch108.wav new file mode 100644 index 00000000..77de09fc Binary files /dev/null and b/design/channels/sound/out/ch108.wav differ diff --git a/design/channels/sound/out/ch201.wav b/design/channels/sound/out/ch201.wav new file mode 100644 index 00000000..5792be05 Binary files /dev/null and b/design/channels/sound/out/ch201.wav differ diff --git a/design/channels/sound/out/ch202.wav b/design/channels/sound/out/ch202.wav new file mode 100644 index 00000000..22bd5116 Binary files /dev/null and b/design/channels/sound/out/ch202.wav differ diff --git a/design/channels/sound/out/ch203.wav b/design/channels/sound/out/ch203.wav new file mode 100644 index 00000000..38e7789f Binary files /dev/null and b/design/channels/sound/out/ch203.wav differ diff --git a/design/channels/sound/out/ch204.wav b/design/channels/sound/out/ch204.wav new file mode 100644 index 00000000..ab00d622 Binary files /dev/null and b/design/channels/sound/out/ch204.wav differ diff --git a/design/channels/sound/out/ch205.wav b/design/channels/sound/out/ch205.wav new file mode 100644 index 00000000..32f7a165 Binary files /dev/null and b/design/channels/sound/out/ch205.wav differ diff --git a/design/channels/sound/out/ch206.wav b/design/channels/sound/out/ch206.wav new file mode 100644 index 00000000..f86127ae Binary files /dev/null and b/design/channels/sound/out/ch206.wav differ diff --git a/design/channels/sound/out/ch301.wav b/design/channels/sound/out/ch301.wav new file mode 100644 index 00000000..27601841 Binary files /dev/null and b/design/channels/sound/out/ch301.wav differ diff --git a/design/channels/sound/out/ch302.wav b/design/channels/sound/out/ch302.wav new file mode 100644 index 00000000..0d2f5a52 Binary files /dev/null and b/design/channels/sound/out/ch302.wav differ diff --git a/design/channels/sound/out/ch303.wav b/design/channels/sound/out/ch303.wav new file mode 100644 index 00000000..787474e4 Binary files /dev/null and b/design/channels/sound/out/ch303.wav differ diff --git a/design/channels/sound/out/ch304.wav b/design/channels/sound/out/ch304.wav new file mode 100644 index 00000000..394c05bc Binary files /dev/null and b/design/channels/sound/out/ch304.wav differ diff --git a/design/channels/sound/out/ch305.wav b/design/channels/sound/out/ch305.wav new file mode 100644 index 00000000..4d07f1d6 Binary files /dev/null and b/design/channels/sound/out/ch305.wav differ diff --git a/design/channels/sound/out/ch306.wav b/design/channels/sound/out/ch306.wav new file mode 100644 index 00000000..217c74be Binary files /dev/null and b/design/channels/sound/out/ch306.wav differ diff --git a/design/channels/sound/out/ch307.wav b/design/channels/sound/out/ch307.wav new file mode 100644 index 00000000..a55f581c Binary files /dev/null and b/design/channels/sound/out/ch307.wav differ diff --git a/design/channels/sound/out/ch308.wav b/design/channels/sound/out/ch308.wav new file mode 100644 index 00000000..092a6d67 Binary files /dev/null and b/design/channels/sound/out/ch308.wav differ diff --git a/design/channels/sound/out/ch309.wav b/design/channels/sound/out/ch309.wav new file mode 100644 index 00000000..12556c57 Binary files /dev/null and b/design/channels/sound/out/ch309.wav differ diff --git a/design/channels/sound/out/ch310.wav b/design/channels/sound/out/ch310.wav new file mode 100644 index 00000000..532c85db Binary files /dev/null and b/design/channels/sound/out/ch310.wav differ diff --git a/design/channels/sound/out/ch401.wav b/design/channels/sound/out/ch401.wav new file mode 100644 index 00000000..cdb9c34b Binary files /dev/null and b/design/channels/sound/out/ch401.wav differ diff --git a/design/channels/sound/out/ch601.wav b/design/channels/sound/out/ch601.wav new file mode 100644 index 00000000..4be0bb7c Binary files /dev/null and b/design/channels/sound/out/ch601.wav differ diff --git a/design/channels/sound/out/ch602.wav b/design/channels/sound/out/ch602.wav new file mode 100644 index 00000000..42d913b1 Binary files /dev/null and b/design/channels/sound/out/ch602.wav differ diff --git a/design/channels/sound/out/ch603.wav b/design/channels/sound/out/ch603.wav new file mode 100644 index 00000000..dd9a5d92 Binary files /dev/null and b/design/channels/sound/out/ch603.wav differ diff --git a/design/channels/sound/out/ch604.wav b/design/channels/sound/out/ch604.wav new file mode 100644 index 00000000..a63062c8 Binary files /dev/null and b/design/channels/sound/out/ch604.wav differ diff --git a/design/channels/sound/out/ch605.wav b/design/channels/sound/out/ch605.wav new file mode 100644 index 00000000..141e6ffc Binary files /dev/null and b/design/channels/sound/out/ch605.wav differ diff --git a/design/channels/sound/out/ch611.wav b/design/channels/sound/out/ch611.wav new file mode 100644 index 00000000..0b9e25ba Binary files /dev/null and b/design/channels/sound/out/ch611.wav differ diff --git a/design/channels/sound/out/ch612.wav b/design/channels/sound/out/ch612.wav new file mode 100644 index 00000000..020a3102 Binary files /dev/null and b/design/channels/sound/out/ch612.wav differ diff --git a/design/channels/sound/out/ch613.wav b/design/channels/sound/out/ch613.wav new file mode 100644 index 00000000..9eed81cc Binary files /dev/null and b/design/channels/sound/out/ch613.wav differ diff --git a/design/channels/sound/out/channels-spectrograms.png b/design/channels/sound/out/channels-spectrograms.png new file mode 100644 index 00000000..ea1a0737 Binary files /dev/null and b/design/channels/sound/out/channels-spectrograms.png differ