Welcome to EarSketch Q&A, where you can ask questions and receive answers from other members of the community.
Use the search bar in the top right corner to see if someone with similar questions as yours has already started a discussion about it. They may have already provided answers to your questions.

362 questions

332 answers

72 comments

614 users

I need AID for my Jukebox

+5 votes
So, like "Jukebox" pretty self-explanatory i need to play three different function (songs) individually all in one file. It looks CLEAN, but the only part i'm messing up on is playing each function individually. EAR SKETCH ADMINS! I ASK TO LEND ME YOUR KNOWLEDGE! please.

"use strict";

// javascript code

// script_name:

//

// author:

// description:

//

init();

setTempo(100);

var Jukebox = ["Indie","Synthpop","Rock"];

var track = readInput("Choose a song:Indie, Synthpop, or Rock.");

{

if (track == "Indie" || track == "indie")

 println("Nice Choice!");

var endMeasure = 26;

var Indie = [Y07_HI_HAT, //index = 0 use: Indie[0]

            Y07_WAH_GUITAR, //index = 1 use: Indie[1]

            RD_UK_HOUSE_SOLODRUMPART_8, //index = 2 use: Indie [2]

            RD_CINEMATIC_SCORE_DRUMPART_11]; //index = 3 use: Indie [3]

 fitMedia(Indie[0], 1, 1, 13);

 fitMedia(Indie[1], 2, 5, endMeasure);

 fitMedia(Indie[2], 3, 1, endMeasure);

 fitMedia(Indie[3], 4, 13, 26);

}

{

if (track == "Synthpop" || track == "Synth" || track == "pop");

 println("Awesome!");

var endMeasure = 24;

var Synthpop = [YG_HIP_HOP_PIANO_5, // index = 0 use: Synthpop[0]

               YG_NEW_FUNK_ELECTRIC_PIANO_2, // index = 1 use: Synthpop[1]

               RD_RNB_808SOLODRUMS_12, // index = 2 use: Synthpop[2]

               DUBSTEP_DRUMLOOP_PART_003]; //index = 3 use: Synthpop[3]

 fitMedia(Synthpop[0], 5, 1, 5);

 fitMedia(Synthpop[1], 6, 5, endMeasure);

 fitMedia(Synthpop[2], 7, 5, endMeasure);

 fitMedia(Synthpop[3], 8, 1, 5);

}

{

if (track == "Rock" || track == "rock");

 println("Cool!");

var endMeasure = 26;

var Rock = [RD_ROCK_POPELECTRICLEAD_13, // index = 0 use: Rock[0]

           RD_ROCK_POPRHYTHM_MAINDRUMS_17, // index = 1 use: Rock [1]

           ELECTRO_MOTORBASS_002]; // index = 2 use: Rock [2]

 fitMedia(Rock[0], 9, 1, endMeasure);

 fitMedia(Rock[1], 10, 1, endMeasure);

 fitMedia(Rock[2], 11, 1, endMeasure);

}

finish();
asked Dec 20, 2017 in DAW by RamosChristopher (240 points)

1 Answer

0 votes

Okay-- we have figured this out!   You did not define your functions, instead you put each block inside of curly brackets.  Take a look at chapter 9 (https://earsketch.gatech.edu/earsketch2/#?curriculum=2-1-0&language=javascript) for examples of how to define and call functions. The if statements won't be part of the function definitions or calls, but everything inside of each if condition will be replaced by a call to a custom function.  

You will need to add a section of code defining each function as a song

answered Dec 21, 2017 by earsketch_admin (6,020 points)
...