Coder Social home page Coder Social logo

name-that-song's Introduction

Name That Song

An automated version of a drinking game that my friends and I play. The rules are fairly simple:

  • One person, called the moderator, chooses an artist for the game.
  • Create a playlist based on the artist - manually, we would use Spotify radio.
  • A song is randomly chosen from the playlist and played for a length of time decided on by the moderator.
  • The players get to "buzz in" by hitting the table. Once a player has buzzed in, he or she must answer.
  • The first player to buzz in answers first and is given a length of time decided on by the moderator to give the song name and artist of the song that has just been played.
  • The player must match the song name and artist exactly with a few exceptions:
    • If a song name has a parenthetical, e.g. You Spin Me Right Round ( Like a Record ), a player may exclude the parenthetical portion of the title without penalty.
    • If a song has several artists, e.g. Walk This Way by Aerosmith ( feat. Run DMC ), a player may exclude or include any featured artists, so long as he or she names the first artist.
  • If the player correctly names the song or artist before the moderator calls time, he or she is awarded 1 point.
  • If the player incorrectly names the song or artist, or the moderator calls time, he or she loses 1 point.
    • Players may have a negative score.
  • Players continue guessing in the order that they buzzed in until someone is awarded a point or no one else has buzzed in.
  • The game continues in this manner until someone reaches five points, with the additional condition that the winner must be two points ahead of the player in second place.
    • If a player reaches 5 points without being ahead of the second place player, play continues until 1 player has more than 5 points and is 2 points ahead of the player in second place.

In order to automate this process, some rules are modified:

  • The moderator may play. His or her only role is to pick an artist used to generate a playlist.
  • A song is played by looking it up using the Spotify API. The preview track returned is used, so a song will only be played for the duration of the preview track - typically 30 seconds.
  • Players must guess while the song is playing. After a song has ended, guessing stops.
  • Buzzing in is not required, so buzz order is not respected. Any player guessing correctly in the allowed time slot will be awarded a point and any player guessing incorrectly will lose a point. Players may abstain from guessing and neither lose nor gain points.

Installing

  1. Install NodeJS

  2. Install global dependencies from NPM by running the following commands in a terminal

    npm install -g babel
    
    npm install -g browserify
    
    npm install -g bunyan
    
    npm install -g gulp
    
  3. Navigate to the project root and run

    npm install
    

    to install project dependencies

  4. Obtain an Echo Nest API key and place it in the privateProperties.js file

    module.exports = {
        echonestApiKey: '<your_api_key>'
    };
    
  5. Download and install MongoDB

    • Create a database to store the data for this application.
    • Remember that privateProperties.js files from step 4? It's time to add a new property to it
    mongoUrl: 'mongodb://<url_of_mongo_server>/<database_name>'
    
    • Make sure mongod is running when you start the application! Otherwise, you're going to be seeing database errors everywhere.
  6. Add properties for sending emails

    • This app includes functionality to send an email to a user with a new password if the user forgets his/her password. You will need to add credentials to an email account that you own for this to work.

    • Note about Gmail accounts: If you would like to send emails from a Gmail account, you'll need to allow the account to be accessed by less secure apps.

    • Add the following properties to the privateProperties.js file:

    emailService: <email_service_to_use>,
    emailUsername: <username_of_email_account_to_use>,
    emailPassword: <password_to_email_account>
    

Building/Running Web App

Navigate to <project_root>/webapp and use a terminal to run

gulp

This will run the default gulp task, which builds the web app and moves the built files into the <project_root>/webapp/public folder. Once this process is complete, deploy the webapp/public folder to your favorite http server. An easy to use, lightweight http server is http-server. It can be installed by using the following command in a terminal

npm install -g http-server

Afterwards, navigate to the <project_root>/webapp folder and use a terminal to run

http-server

http-server will automatically deploy index.html from the public folder to http://localhost:8080

Running Server App

In order for the webapp to work, the server side component needs to be running To start the server app, navigate to <project_root>/app and use a terminal to run

node index.js

To prettify logging statements in the terminal, you can pipe the output through the bunyan CLI installed in step 2 of the installation instructions like so:

node index.js | bunyan

The server app will deploy to localhost on the port specified by the port property of app/config/appProperties.js ( this is defaulted to port 8008 )

Known Issues

  • Source maps are not generating correctly

name-that-song's People

Contributors

eric-carlton avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.