Author Topic: Display-Specific Music?  (Read 23603 times)

calle81

  • Sr. Member
  • ****
  • Posts: 184
    • View Profile
Re: Display-Specific Music?
« Reply #15 on: March 17, 2018, 12:51:26 PM »
Second, let me understand what you are asking... you want unique music on a per-title basis? So like Galaga has it's own song, and Ms. Pacman has another song?

I will only use it for the displays menu. So Nes, snes etc can have music that overrides the video snaps music. I found a simple workaround:

////////////////
//Background Music
////////////
local bgMusic = fe.add_sound("")
function bgmusic_transitions( ttype, var, ttime ) {
 switch ( ttype ) {
  case Transition.FromOldSelection:
           bgMusic.playing=false
         bgMusic.file_name = "../../music/"+fe.game_info(Info.Title)+".mp3"
            bgMusic.playing=true
            bgMusic.loop=true
  break;
  case Transition.ToGame:
  case Transition.ToNewList:
         bgMusic.playing=false
         bgMusic.file_name = "../../music/"+fe.game_info(Info.Title)+".mp3"
            bgMusic.playing=true
            bgMusic.loop=true
  break;
  }
 return false;
}

iOtero

  • Sr. Member
  • ****
  • Posts: 414
    • View Profile
Re: Display-Specific Music?
« Reply #16 on: November 26, 2018, 05:44:09 AM »
I will only use it for the displays menu. So Nes, snes etc can have music that overrides the video snaps music. I found a simple workaround:

////////////////
//Background Music
////////////
local bgMusic = fe.add_sound("")
function bgmusic_transitions( ttype, var, ttime ) {
 switch ( ttype ) {
  case Transition.FromOldSelection:
           bgMusic.playing=false
         bgMusic.file_name = "../../music/"+fe.game_info(Info.Title)+".mp3"
            bgMusic.playing=true
            bgMusic.loop=true
  break;
  case Transition.ToGame:
  case Transition.ToNewList:
         bgMusic.playing=false
         bgMusic.file_name = "../../music/"+fe.game_info(Info.Title)+".mp3"
            bgMusic.playing=true
            bgMusic.loop=true
  break;
  }
 return false;
}

Nice code, i'll take it... Thanks  8)
Nacer a los 15 años Una novela de iOtero

calle81

  • Sr. Member
  • ****
  • Posts: 184
    • View Profile
Re: Display-Specific Music?
« Reply #17 on: November 26, 2018, 11:13:29 PM »
Quote
Nice code, i'll take it... Thanks  8)

Cool! Oomek helped me get this right :) Be aware that there is currently a bug that makes AM crash when a song ends and loop is set to true:

https://github.com/mickelson/attract/issues/510

iOtero

  • Sr. Member
  • ****
  • Posts: 414
    • View Profile
Re: Display-Specific Music?
« Reply #18 on: November 27, 2018, 03:40:25 AM »
Quote
Nice code, i'll take it... Thanks  8)

Cool! Oomek helped me get this right :) Be aware that there is currently a bug that makes AM crash when a song ends and loop is set to true:

https://github.com/mickelson/attract/issues/510

Ok. Thanks.  ;D
Nacer a los 15 años Una novela de iOtero

ugoboss

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Display-Specific Music?
« Reply #19 on: September 21, 2021, 10:00:14 AM »
OK, I attached the plug-in. Tried to make it presentable. There's not much in the way of comments, error handling or logging.

How to use:
  • Create a parent folder to hold your music (or ambient sounds). Mine is "Music".
  • Within that folder, create subfolders with names matching the displays for which you want music to play. For example, my "Music/Hack & Slash" folder contains all the music I want to play when users are browsing Hack & Slash games. If you don't want music for a display, don't make a folder for it.
  • Now enable the plugin in AttractMode and specify your parent folder as "Source Directory".

Ignore the other options for now. With this basic configuration you should get unique playlists for whichever displays you want to have music. Be aware there is no checking for illegal characters, so I guess if you put weird characters in your display names you might run into problems creating folders with matching names.

This isn't a jukebox, so although it's based on AudioMode (thanks to whoever wrote that) a lot of that functionality is stripped out. It just plays random music from the appropriate subfolder, and it restarts every time you leave and then return to whatever display the music is associated with.

I added the Alternate Source options in case someone wanted to offer a B-track. It works exactly the same. Just create a second parent folder, with subfolders named after whatever displays you want to play music. Then assign a key to toggle between the original music and the alternate music. This is optional, and hitting the toggle when no alternate source is defined will not do anything. As an example, I have "Music" as my original source, and I have "Music_Chiptunes" as an alternate set of music.

If you use the alternate source options, make sure in your attract.cfg file the value specified for "layout" under each "display" entry is exactly right. The values are case-sensitive. So in my case, I was getting weird behavior if layout was specified as "flavors" rather than the correct "Flavors". It caused the plug-in to reload and it messed up the toggling between the original and alternate music whenever I viewed a display with a misspecified layout.

Finally, in my set-up I have displays where I don't want music, but I want to hear the sound of the snap videos being shown. I also don't want the video sounds to play underneath music. I accomplished this outside of the DisplayMusic plugin. In my layout.nut, I used the video_flags (Vid.Default and Vid.NoAudio) to mute the videos for displays with music, and to play the video sounds in the display with no music.

For anyone who wants display-specific music, I hope this helps.
hello, sorry if I open this speech after a long time and sorry for my English which is clearly translated from Italian. I wish I could be helped as the "display music" plugin unfortunately does not work, I need to be able to activate it as I have a whole collection without sound and therefore I would like to use an mp3 music file to be able to compensate for this silence as I scroll with the games wheel. I downloaded the plugin and followed the instructions by creating a music folder and a sub-folder of the displey that interests me, inside it I put an mp3 file, I activated the plugin but the display continues to remain silent, I tried with the "audio" plugin mode "and this works fine but the music expands to all displays, so that plugin isn't for me. I kindly ask you to help me to solve the configuration of the "display music" plugin, thanks