I7: Implement an FM Radio that plays songs from a list for specified amounts of times?

I want to create an FM radio (this is the 80s) that plays a list of songs for particular durations. The songs should cycle regardless of whether the player is nearby to hear them. I’d like to have this flexible so I can modify the playlist/times easily…maybe a table? The whole game is timed and actions take different amounts of time. The radio should work in relation to the elapsed game time.

2 Likes

I threw together this quick prototype, which of course you’ll want to adapt to your own situation:

``````Living Room is a room. The FM radio is a device in Living Room with description "A snazzy Japanese-made portable radio made of ruggedized plastic. You can take it to the beach!". The FM radio is switched off.

The radio has a number called the current table row. The radio has a number called the current song playtime. The current table row of the radio is 1. The current song playtime of the radio is 1.

Every turn:
increase the current song playtime of the radio by one;
let R be the current table row of the radio;
let the maximum playtime be the duration in row R of the Table of Radio Songs;
if the current song playtime of the radio is greater than the maximum playtime:
let the old song be the title in row R of the Table of Radio Songs;
now the current song playtime of the FM radio is one;
if the current table row of the radio is less than the number of rows in the Table of Radio Songs:
increase the current table row of the radio by one;
otherwise:
now the current table row of the radio is one;
if the player can see the FM radio and the FM radio is switched on:
now R is the current table row of the FM radio;
say "As '[old song]' fades out, the radio begins playing '[title in row R of the Table of Radio Songs].' [reaction in row R of the Table of Radio Songs][paragraph break]";
otherwise:
if the player can see the FM radio and the FM radio is switched on:
say "The radio continues to play '[title in row R of the Table of Radio Songs].'".

Title								Duration	Reaction
"Time After Time"					3			"Too soppy, you think to yourself. Besides, it reminds you of your ex, who always insisted that this was Our Song."
"Purple Rain"						4			"You're not a big Prince fan, but this song always kinds of tugs at your heartstrings. Or maybe your groin."
"Beat It"							4			"Has Michael Jackson ever demonstrated his vocal skills so finely?"
"I Melt With You"					3			"For a song about nuclear war, this sure is upbeat."
"Life During Wartime"				4			"Thankfully, there are no war zones near you at the moment."
"Modern Love"						5			"It's [italic type]Bowie Time![roman type], you think to yourself, excited."
"Straight Outta Compton"			4			"Not exactly the kind of music this station usually plays, but you're glad they're stretching out of their comfort zone."
"What's Love Got to Do With It"		4			"[italic type]God[roman type], what a voice, you think."
"Take On Me"						3			"You tap your foot. It's catchy."
"Africa"							4			"This is that melody that you catch yourself humming when you wake up some mornings."
"Just a Friend"						5			"You've been there. You know how Biz feels."
"Whip It"							4			"You're not sure what this is about, but it sounds kind of subversive."
"Man Eater"						3			"You hope musicians [italic type]never[roman type] stop using saxophone parts like this."
``````

Songs can take different amounts of time, and the current song count keeps advancing even if the radio is turned off. I’m assuming that each turn takes one minute, and one downside is that songs in the example are currently only tested as taking an integral number of minutes; since the “current playtime” is always reduced down to exactly one minute when the song changes, there’s no point to fractional times at the moment (3.2 or 3.7 is effectively the same as 4 turns).

EDIT. I did not check to see what the actual playtime of the songs in the table is.

11 Likes

I was expecting a nudge in the right direction, not an example or prototype, so I appreciate this very much. Thanks.

1 Like

I was coming here to see if I could get any advice on setting up a jukebox that would ‘play’ different songs over time, and this is one of the newest threads. Fantastic!

2 Likes