AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [ALL] Karaoke (https://forums.alliedmods.net/showthread.php?t=102670)

Theme97 09-04-2009 21:55

[ALL] Karaoke
 
2 Attachment(s)
Requirements
- clientprefs. This plugin saves players' volume and offset settings for their convenience.
- setup. It’s going to take you quite a bit of time to get everything working.
- web server with PHP. Songs are played through HTML MOTDs, so you’ll need to be able to serve the PHP pages.
- file host. You need somewhere to put the songs, of course. This can be the same as the web server if you’d like.
- MP3 files. This is the most common, lossy codec available, so we’re going with these. Small filesizes are better, so the bit rate should be at most 128 kbps.
- LRC files. The plugin uses these for song information (title, artist, etc.) and, well, lyrics.

Got these? Good. Now on to installation!

Installation
1) You will need a public place to store the audio files (see "file host" above). You can use your webhost if you like. All music must be placed in one folder. Remember the URL of this folder for later steps.

2) You will need a web server with PHP. Upload the contents of Karaoke_www.zip and remember the URL for "play.php". You must edit this file! You need to specify the URL of the audio folder from step #1. The line which you should edit is clearly marked; be sure not to change anything else unless you know what you are doing.

3) Download the attached plugin (click "Get Plugin" for the .smx) and place it in addons\sourcemod\plugins

4) Create the following file:
addons\sourcemod\data\karaoke.txt
The first line should contain the URL for play.php from step #2.

5) Create the following folder:
addons\sourcemod\data\karaoke\
In this folder should be .lrc files with names that match the .mp3 files on your server. For example, if you have a file called LonelyIsland_LikeABoss.lrc, the matching MP3 file should be called LonelyIsland_LikeABoss.mp3 or else it will not work. For more information on .lrc files, see below.

6) In-game and as an admin with the slay flag, type /k or /karaoke and a menu should pop up listing songs found in your karaoke folder. If a song is not there, check error logs, as there may be a problem with the .lrc file. Alternatively, you can type /kvote and up to six songs will be randomly chosen for you to choose. The song with the most votes after 20 seconds will be selected.

7) The announcer should count down from 20 seconds with an accompanying centertext explaining that you may change your volume with /vol #. While this happens, players may hear the song faintly in the background, as this is an attempt to preload the song so that it won't be too out of sync. Another command is /offset, which allows you to change how much later or earlier the music and lyrics will display. Type /offset for more instructions on how to use it.

8) The music should play, and if the .lrc file was written well, the centertext-ed lyrics should display with the music. The timing should not be too far off, as the lyrics are meant to display earlier than they occur in the music so that singers have time to prepare for the next line, but there still may be some cases of the music playing too late. I will see if there are any ways of fixing this.

9) That's it! Enjoy singing along while killing people!

Commands
  • /k or /karaoke will pop up a menu that will allow you to choose a sorting method (title, artist, or album), which will then allow you to choose an individual song. Requires SLAY admin flag.
  • /kstop will prematurely end the current song. Lyrics and music should stop playing, and you should be able to pick a new song immediately.
  • /kvote picks 6 random songs and sends a vote to all players. After 20 seconds, the votes are collected and the winning song is played. Requires SLAY admin flag.
  • /offset changes how early or late the song or lyrics will play. This is on a per-client basis and only has effect before a song is chosen. Type /offset for more information.
  • /vol changes the volume of the songs. This is per-client and can be changed mid-song at the cost of possible desyncing.

.lrc Files
The beginning of a .lrc file should contain metadata for the song. These are in "tags", which are of the following format:
[tag:information]

Possible .lrc tags that can be used include:
  • ti: Song title. This is required.
  • ar: Artist. Also required.
  • al: Album.
  • offset: Offset in milliseconds. The music will be delayed by this much when it is played (e.g. [offset:2000] will display lyrics two seconds earlier). Can be negative.
  • by: .lrc author identification. Not really "supported" since all other tags are ignored, but credit is always nice to have.

Following this should be lines with timestamps and text, like so:

[0:12.34]Hello, world!

For the above line, 12.34 seconds after the song starts, "Hello, world!" will display on the screen. If there is a line after it, "Hello, world!" will stay on screen until the next line. If you do not want this to happen, you can just put nothing after a timestamp for a blank line.

If you want to use newlines, you can use either \n or | as a newline delimiter.

UTF-8 .lrc files are supported, as the plugin will remove the BOM (\xEF\xBB\xBF). However, I'm not sure what else will or won't work, so you will have to find out for yourself.

For examples of .lrc files that work with Karaoke, you can see my works here.

Changelog
19 September 2009 - 1.2
- The plugin actually works again.
- Songs menu now lets you sort by artist, title, or album.
- Fixed bug where the song would not be considered "finished" when it was.

17 September 2009 - 1.1
- No longer dependent on TF2.
- Music offset limits changed to ±5.0 seconds.
- Lyrics now play 0.5 seconds later than before.
- /vol now changes volume mid-song at the cost of some desyncing.
- Added two new commands: /kstop and /kvote. Both require the slay flag.
- Fixed an error message when attempting to show lyrics after the song is over.
- "of" tag changed to "offset"; now represents milliseconds to be subtracted from timestamps.

---

Note: This is nowhere near as secure as SirLamer's Jukebox plugin. You have been warned. You claim responsibility by installing this plugin. If you'd like to contribute a patch for this (or anything), I'd be happy to include it.

Jindo 09-05-2009 03:27

Re: [TF2] Karaoke
 
Haha, you're awesome!

I will certainly be testing this :)

Flyflo 09-05-2009 04:56

Re: [TF2] Karaoke
 
Yeah, I'll test it as soon as possible.
Lots of our players wanted a karaoke plugin.

Theme97 09-05-2009 06:31

Re: [TF2] Karaoke
 
Hmm. A few more notes on stuff:

In .lrc parsing, newlines are denoted by either | or \n
Lines are persistent (they will remain on screen until another line is displayed). Blank lyric lines will force it to go away.
These two features mean you can make .lrc files like a boss:
Code:

[ar:The Lonely Island]
[ti:Like a Boss]
[cr:EnigmatiK]
[00:00.46]Mr. Samberg, thanks for coming to your performance review.\n
[00:02.86]\nNo problem.
[00:03.66]So you're in charge around here, is that fair to say?\n
[00:06.06]\nAbsolutely. I'm the boss.
[00:07.86]Okay, so take us through a day in the life of \'The Boss\'.\n
[00:11.06]\nWell the first thing I do is
[00:12.46]Talk to Corporate\n
[00:13.26]Talk to Corporate\nLIKE A BOSS
[00:13.86]Approve memos\n
[00:14.86]Approve memos\nLIKE A BOSS
[00:15.66]Lead a workshop\n
[00:16.46]Lead a workshop\nLIKE A BOSS
[00:17.06]Remember birthdays\n
[00:18.06]Remember birthdays\nLIKE A BOSS
[00:18.66]Direct work flow\n
[00:19.66]Direct work flow\nLIKE A BOSS
[00:20.26]My own bathroom\n
[00:21.26]My own bathroom\nLIKE A BOSS
[00:22.06]Micromanage\n
[00:22.86]Micromanage\nLIKE A BOSS
[00:23.46]Promote synergy\n
[00:24.46]Promote synergy\nLIKE A BOSS
[00:25.26]Hit on Deborah\n
[00:26.06]Hit on Deborah\nLIKE A BOSS
[00:26.86]Get rejected\n
[00:27.66]Get rejected\nLIKE A BOSS
[00:28.46]Swallow sadness\n
[00:29.26]Swallow sadness\nLIKE A BOSS
[00:30.06]Send some faxes\n
[00:30.86]Send some faxes\nLIKE A BOSS
[00:31.66]Call a sex line\n
[00:32.46]Call a sex line\nLIKE A BOSS
[00:33.28]Cry deeply \n
[00:34.06]Cry deeply \nLIKE A BOSS
[00:34.66]Demand a refund\n
[00:35.66]Demand a refund\nLIKE A BOSS
[00:36.46]Eat a bagel\n
[00:37.26]Eat a bagel\nLIKE A BOSS
[00:37.86]Harassment lawsuit\n
[00:38.86]Harassment lawsuit\nLIKE A BOSS
[00:39.66]No promotion\n
[00:40.46]No promotion\nLIKE A BOSS
[00:41.26]Fifth of vodka\n
[00:42.06]Fifth of vodka\nLIKE A BOSS
[00:42.76]Shit on Deborah's desk\n
[00:43.66]Shit on Deborah's desk\nLIKE A BOSS
[00:44.46]Buy a gun  \n
[00:45.26]Buy a gun  \nLIKE A BOSS
[00:46.06]In my mouth\n
[00:46.86]In my mouth\nLIKE A BOSS
[00:47.46]Oh, fuck man, I can't fucking do it, shit!
[00:50.68]Pussy out  \n
[00:51.68]Pussy out  \nLIKE A BOSS
[00:52.48]Puke on Deborah's desk\n
[00:53.28]Puke on Deborah's desk\nLIKE A BOSS
[00:53.88]Jump out the window\n
[00:54.88]Jump out the window\nLIKE A BOSS
[00:55.48]Suck a dude's dick\n
[00:56.48]Suck a dude's dick\nLIKE A BOSS
[00:57.28]Score some coke\n
[00:58.08]Score some coke\nLIKE A BOSS
[00:58.88]Crash my car\n
[00:59.68]Crash my car\nLIKE A BOSS
[01:00.48]Suck my own dick\n
[01:01.28]Suck my own dick\nLIKE A BOSS
[01:02.08]Eat some chicken strips\n
[01:02.88]Eat some chicken strips\nLIKE A BOSS
[01:03.68]Chop my balls off\n
[01:04.48]Chop my balls off\nLIKE A BOSS
[01:05.28]Black out in the sewer\n
[01:06.08]Black out in the sewer\nLIKE A BOSS
[01:06.88]Meet a giant fish\n
[01:07.68]Meet a giant fish\nLIKE A BOSS
[01:08.48]Fuck his brains out\n
[01:09.28]Fuck his brains out\nLIKE A BOSS
[01:10.08]Turn into a jet\n
[01:10.88]Turn into a jet\nLIKE A BOSS
[01:11.68]Bomb the Russians\n
[01:12.48]Bomb the Russians\nLIKE A BOSS
[01:13.28]Crash into the sun\n
[01:14.08]Crash into the sun\nLIKE A BOSS
[01:14.88]Now I'm dead\n
[01:15.68]Now I'm dead\nLIKE A BOSS
[01:16.88]Uh-huh. So, that's an average day for you, then?\n
[01:20.28]\nNo doubt.
[01:21.48]You chopped your balls off and died.\n
[01:23.28]\nHell yeah!
[01:24.68]And I think at, uh, one point there, you said something about sucking your own dick?\n
[01:28.48]\nNope.
[01:29.28]Actually, I'm pretty sure you did.\n
[01:31.08]\nNah, that ain't me.
[01:32.88]Okay, well, this has been eye opening for me.\n
[01:35.48]\nI'm the boss.
[01:36.48]Yeah, no, I got that. You said it about 400 times.\n
[01:39.08]\nI'm the boss.
[01:40.08]Yeah, yeah, I got it.\n
[01:40.88]\nI'm the boss.
[01:41.68]No, I heard you. See you later!\n
[01:44.48]LIKE A BOSS

The song cannot be changed until 5 seconds after the last line. For quick testing, just reload the plugin and restart the song.
Volume and offsets only change before the song starts. Only /vol 0 has any immediate effects. I plan to implement mid-song volume changing soon.

This stuff will probably be added to the OP if this plugin actually goes anywhere.

Flyflo 09-05-2009 13:25

Re: [TF2] Karaoke
 
If you Disable HTML MOTDs you won't be able to hear the music, but I think it's not fixable. Anyway it's not a big problem.

andex 09-05-2009 13:44

Re: [TF2] Karaoke
 
Couple of questions, but first of all thank you!!


1. Is there anyway to stop Karaoke once it has started?
I think I screwed something up with my lrc file, and the music didn't start playing, but it keeps saying, "Please wait until the song is done", when I do /karaoke.


2. I keep the lrc files in the sourcemod/data/karaoke folder, where do I keep the music?
Right now I have the play.php on a webserver, and I edited the php file to point to the same folder that it is in, where the MP3's are at. Am I doing this right?

3. This isn't specific to your plugin, but I figured I could stop karaoke if I do a sm plugins unload_all and then reload everything, but... anytime I do a sm plugins unload_all or any sm plugins * command, all it does is list the plugins I have installed. Any ideas?

Theme97 09-05-2009 15:46

Re: [TF2] Karaoke
 
Quote:

Originally Posted by Flyflo (Post 923880)
If you Disable HTML MOTDs you won't be able to hear the music, but I think it's not fixable. Anyway it's not a big problem.

Ah, I'd forgotten about that. I started writing this before that option came out anyway. Oh well, it's better than having to download a whole library of songs upon joining a server.

Quote:

Originally Posted by andex (Post 923904)
1. Is there anyway to stop Karaoke once it has started?
I think I screwed something up with my lrc file, and the music didn't start playing, but it keeps saying, "Please wait until the song is done", when I do /karaoke.

Not yet, other than reloading the plugin.

If the music doesn't play, then there's probably one of two problems. Either your have HTML MOTDs disabled (see above) or the mp3s aren't in the right place (see below).

Quote:

Originally Posted by andex (Post 923904)
2. I keep the lrc files in the sourcemod/data/karaoke folder, where do I keep the music?
Right now I have the play.php on a webserver, and I edited the php file to point to the same folder that it is in, where the MP3's are at. Am I doing this right?

Sounds right, but I'll go over it with an example just to make sure.

In sourcemod/data/karaoke.txt (the text file) should be a line containing the URL to your play.php. For example, we'll use

Code:

http://www.example.com/karaoke/play.php
Once that line is saved to the sourcemod/data/karaoke.txt file, Karaoke should be using that URL (though I only added this method after my last chance to test, so I'm not sure if there are any problems with this).

The source for that page should have that edited URL somewhere, which, for our example, will be

Code:

http://www.filehost.com/andex/karaoke/
In this folder should be .mp3 files with names that match your .lrc files.

So here's a recap. If your sourcemod/data/karaoke/ folder has the following .lrcs
  • LonelyIsland_LikeABoss.lrc
  • Portal_StillAlive.lrc
  • RickAstley_NeverGonnaGiveYouUp.lrc

then your folder at http://www.filehost.com/andex/karaoke/ should contain:
  • LonelyIsland_LikeABoss.mp3
  • Portal_StillAlive.mp3
  • RickAstley_NeverGonnaGiveYouUp.mp3

Then you should be fine.

For anyone who's wondering, I didn't use a cvar for the URL because Source has problems with putting URLs in cvars (at least for me).

Quote:

Originally Posted by andex (Post 923904)
3. This isn't specific to your plugin, but I figured I could stop karaoke if I do a sm plugins unload_all and then reload everything, but... anytime I do a sm plugins unload_all or any sm plugins * command, all it does is list the plugins I have installed. Any ideas?

I'm not sure why that's happening, but the easiest way to do reload it is simply
Code:

sm plugins reload Karaoke

noodleboy347 09-05-2009 17:52

Re: [TF2] Karaoke
 
Someone should make a pack of awesome songs :D

Theme97 09-05-2009 22:36

Re: [TF2] Karaoke
 
I don't mind making .lrc files as long as I'm not expected to make them immediately.

Perhaps someone could make a list and I can get started.

andex 09-05-2009 22:48

Re: [TF2] Karaoke
 
I have uploaded the ones (lrc's) I have:

http://www.troubleshootcode.com/public



On my server, some people hear the music some people don't.. I don't hear the music, but others do. I do not have disable MOTD on either.


All times are GMT -4. The time now is 13:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.