Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>

<!-- 

Hello Camper!

For now, the test suite only works in Chrome! Please read the README below in the JS Editor before beginning. Feel free to delete this message once you have read it. Good luck and Happy Coding! 

- The freeCodeCamp Team 

-->

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
  
    <link href="https://fonts.googleapis.com/css2?family=Merriweather+Sans&display=swap" rel="stylesheet">
  </head>
  
  <body id="body-background">
    <div id="react-redux-component"></div>
    
    
  </body>
</html>
              
            
!

CSS

              
                :root {
  --body-background-color: url("https://raw.githubusercontent.com/TazExprez/Logos/master/StarWarsBackground.jpg"); 
  
  --show-modal-div: none;
  --show-help-div: none;
  --show-youtube-video-div: none;
  
  --youtube-video-div-background-color: #E4B77D;
  
  --left-arrow-color: #E4B77D;
  --left-arrow-hover-color: yellow;
  --right-arrow-color: #E4B77D;
  --right-arrow-hover-color: yellow;
  --image-border-color: #E4B77D;
  --font-family: "StarWarsFont";
}

@font-face {
  font-family: 'DSEG14ClassicMini-LightFont';
  src: url("https://raw.githubusercontent.com/TazExprez/Logos/master/DSEG14ClassicMini-Light.woff2") format("woff2"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/DSEG14ClassicMini-Light.woff") format("woff"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/DSEG14ClassicMini-Light.ttf") format("truetype"); 
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'StarWarsFont';
  src: url("https://raw.githubusercontent.com/TazExprez/Logos/master/StarWars.woff2") format("woff2"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/StarWars.woff") format("woff"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/StarWars.ttf") format("truetype"); 
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'SchindlersListFont';
  src: url("https://raw.githubusercontent.com/TazExprez/Logos/master/shindlerfont_by_juan_casco-webfont.woff2") format("woff2"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/shindlerfont_by_juan_casco-webfont.woff") format("woff"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/ShindlerFont_by_Juan_Casco.ttf") format("truetype"); 
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'BatmanFont';
  src: url("https://raw.githubusercontent.com/TazExprez/Logos/master/Batman.woff2") format("woff2"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/Batman.woff") format("woff"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/Batman.ttf") format("truetype"); 
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'RockyFont';
  src: url("https://raw.githubusercontent.com/TazExprez/Logos/master/Rocky.woff2") format("woff2"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/Rocky.woff") format("woff"), 
    url("https://raw.githubusercontent.com/TazExprez/Logos/master/Rocky.ttf") format("truetype"); 
  font-weight: normal;
  font-style: normal;
}

#body-background {
  background: var(--body-background-color);
  background-size: cover;
}

#modal-div {
  position: fixed;
  display: var(--show-modal-div);
  z-index: 1;
  background: rgba(0,0,0, 0.7);
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
  overflow: auto;
}

#help-div {
  display: var(--show-help-div);
}

#youtube-video-div {
  display: var(--show-youtube-video-div);
  background: var(--youtube-video-div-background-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 560px;
  height: 335px;
  padding: 0px 10px 10px 10px;
  margin: 40px auto;
  /*This is for the cutout at the top of the div.  The -webkit prefix had to be added so that this would work in iOS 12.*/
  -webkit-clip-path: polygon(0% 7.5%, 93% 7.5%, 93% 0, 90% 0%, 100% 0, 100% 10%, 100% 90%, 100% 100%, 90% 100%, 10% 100%, 0 100%, 0% 90%);
}

#close-youtube-video-span-div-container-div {
  display: flex;
  justify-content: flex-end;
}

#close-youtube-video-span-div {
  width: 20px;
  background: linear-gradient(gold, purple, red, green);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#close-youtube-video-span-div:hover {
  background: linear-gradient(yellow, blue, green, red, orange);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#close-youtube-video-span {
  cursor: pointer;
  font-size: 30px;  
}

#close-youtube-video-span:hover {
  color: rgba(186,85,211, 0.9);
}

#volume-buttons-and-display {
  display: flex;
}

#drum-machine-and-outer-controller {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 20%;
}

#drum-machine-and-outer-controller:focus {
  outline: none;
}

#theme-and-music-picker {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  width: 80%;
}

#theme-and-music-picker:focus {
  outline: none;
}

.theme-and-music-picker-arrows {
  font-size: 60px;
  cursor: pointer;
}

#left-arrow {
  color: var(--left-arrow-color);
}

#left-arrow:hover {
  color: var(--left-arrow-hover-color);
}

#right-arrow {
  color: var(--right-arrow-color);
}

#right-arrow:hover {
  color: var(--right-arrow-hover-color);
}

img {
  border-radius: 10px;
  border: 2px solid var(--image-border-color);
}

#drum-machine {
  display: flex;
  margin-top: 20px;
  padding: 10px;
  height: auto;
  border: 10px solid #E4B77D;
  background: rgba(228,183,125, 0.3);
}

#drum-machine:focus {
  outline: none;
}

#display-and-non-drum-buttons {
  display: flex;
}

#display, #volume-display {
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 2px solid rgb(0,191,255, 0.7);
  height: 70px;
  width: 100px;
  border-radius: 5px;
  color: black;
  /*background: rgb(0,0,0, 0.7);*/
  background: rgba(57,255,20, 0.7);
  text-align: center;
  font-family: 'DSEG14ClassicMini-LightFont';
  font-size: 20px;
  box-sizing: border-box;
}

#volume-display {
  font-size: 30px;
}

#all-drum-pads {
  display: flex;
  flex-direction: column;
}

.drum-pads-row {
  display: flex;
}

button {
  height: 70px;
  width: 100px;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 40px;
  font-style: bold;
  background: linear-gradient(#FFFFFF, #D4AF37);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

button:focus {
  outline: none;
}

.drum-pad-container-div {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 70px;
  width: 100px;
  border-radius: 5px;
  background: rgb(0,191,255, 0.4)
}

.drum-pad-container-div:hover {
  background: rgba(186,85,211, 0.4);
}

/*This span is needed for the linear-gradient text to work in iOS.*/
.drum-pad-letter-span {
  /*These padding and margin properties are used to center the button letters in iOS.*/
  padding-left: 10px;
  padding-right: 10px;
  margin-left: -20px;
  margin-right: -20px;
  /*This had to be repeated in this selector in order for the linear-gradient text to work in iOS.*/
  background: linear-gradient(#FFFFFF, #D4AF37);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/*This was done so that one of the drum pads in Schindler's List could have a reddish color when being hovered over.*/
#a-div:hover {
  color: black;
  background: #BB3F3F;
}

#full-track-container-div {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 70px;
  width: 100px;
  border-radius: 5px;
  background: rgb(0,0,0, 0.7);
}

#full-track-container-div:hover {
  background: rgba(186,85,211, 0.7);
}

#full-track {
  margin: 0;
  font-size: 18px;
  font-family: 'StarWarsFont';
}

#full-track-span {
  padding-left: 10px;
  padding-right: 10px;
  margin-left: -20px;
  margin-right: -20px;
  background: linear-gradient(#FFFFFF, #D4AF37);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#youtube-container-div {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 70px;
  width: 100px;
  border-radius: 5px;
  background: rgb(0,0,0, 0.7);
}

#youtube-container-div:hover {
  background: rgba(255,0,0, 0.7);
}

#youtube-button {
  font-size: 40px;
}

.fa-youtube {
  padding-left: 10px;
  padding-right: 10px;
  margin-left: -20px;
  margin-right: -20px;
  background: linear-gradient(#FFFFFF, #D4AF37);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/*This is for the volume knob.*/
#scroll-wheel-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  padding: 0px;
  border-radius: 100px;
  overflow: hidden;
  background: transparent;
}

/*This is for the volume knob.*/
#scroll-wheel-wrapper #scroll-wheel {
  height: 100%;
  position: relative;
  pointer-events: none;
  background-color: rgb(0,191,255, 0.4);
  border-radius: 50px;
  transform: rotate(180deg);
  border: 1px solid green;
  box-sizing: border-box;
}

/*This is for the volume knob.*/
#scroll-wheel-wrapper #scroll-wheel #thumb {
  touch-action: none;
  -ms-touch-action: none;
  position: absolute;
  cursor: grabbing;
  top: 5px;
  left: 50%;
  width: 5px;
  height: 35px;
  z-index: 200;
  background: linear-gradient(#FFFFFF, #D4AF37);
  border-radius: 0%;
  transform: translate3d(-50%, 0, 0);
}

/*This is for the volume knob.*/
#scroll-wheel-wrapper #interaction-area {
  position: absolute;
  background: transparent;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 900;
  cursor: -webkit-grab;
  cursor: grab;
}

/*This is for the 3 way toggle switch.*/
#radio-buttons-and-sliding-button-container-div {
  position: relative;
  display: inline-block;
  height: 30px;
  width: 120px;
  border: 2px solid black;
  border-radius: 5px;
}

/*This is for the 3 way toggle switch*/
#sliding-button-div {
  position: absolute;
  display: inline-block;
  top: 0;
  height: 30px;
  width: 40px;
  background: green;
  transition: 0.8s;
  border-radius: 3px;
}

/*This is for the 3 way toggle switch.*/
#radio-buttons-div {
  display: flex;
  justify-content: space-between;
}

/*This is for the 3 way toggle switch.*/
.single-option-label {
  width: 100%;
  color: transparent;
}

/*This is for the 3 way toggle switch.*/
.radio-input-class {
  display: none;
}
              
            
!

JS

              
                // !! IMPORTANT README:

// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place.

/***********
INSTRUCTIONS:
  - Select the project you would
    like to complete from the dropdown
    menu.
  - Click the "RUN TESTS" button to
    run the tests against the blank
    pen.
  - Click the "TESTS" button to see
    the individual test cases.
    (should all be failing at first)
  - Start coding! As you fulfill each
    test case, you will see them go  
    from red to green.
  - As you start to build out your
    project, when tests are failing,
    you should get helpful errors
    along the way!
    ************/

// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example!

// Once you have read the above messages, you can delete all comments.

const themesForDrumMachineArray = [["https://raw.githubusercontent.com/TazExprez/Logos/master/StarWars.jpg", "#E4B77D", "yellow", "#E4B77D", "yellow", "#E4B77D", 'url("https://raw.githubusercontent.com/TazExprez/Logos/master/StarWarsBackground.jpg")', "StarWarsFont", "https://raw.githubusercontent.com/TazExprez/Logos/master/StarWarsArrowSound.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/StarWarsPhrase.mp3", "https://www.youtube.com/embed/v5CA6rK2aLQ?enablejsapi=1&version=3&playerapiid=ytplayer&rel=0", "#E4B77D"],
                                   ["https://raw.githubusercontent.com/TazExprez/Logos/master/SchindlersList.jpg", "white", "#BB3F3F", "white", "#BB3F3F", "white", 'url("https://raw.githubusercontent.com/TazExprez/Logos/master/SchindlersListBackground.jpg")', "SchindlersListFont", "https://raw.githubusercontent.com/TazExprez/Logos/master/SchindlersListArrowSound.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SchindlersListPhrase.mp3", "https://www.youtube.com/embed/sFSWlfZ4CXM?enablejsapi=1&version=3&playerapiid=ytplayer&rel=0", "white"],
                                   ["https://raw.githubusercontent.com/TazExprez/Logos/master/Batman.jpg", "lightblue", "white", "lightblue", "white", "white", 'url("https://raw.githubusercontent.com/TazExprez/Logos/master/BatmanBackground.jpg")', "BatmanFont", "https://raw.githubusercontent.com/TazExprez/Logos/master/BatmanArrowSound.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/BatmanPhrase.mp3", "https://www.youtube.com/embed/n_Klu8YTub8?enablejsapi=1&version=3&playerapiid=ytplayer&rel=0", "white"],
                                   ["https://raw.githubusercontent.com/TazExprez/Logos/master/Rocky.jpg", "red", "white", "blue", "white", "white", 'url("https://raw.githubusercontent.com/TazExprez/Logos/master/RockyBackground2.jpg")', "RockyFont", "https://raw.githubusercontent.com/TazExprez/Logos/master/RockyArrowSound.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/RockyPhrase.mp3", "https://www.youtube.com/embed/GVLSIRItfKY?enablejsapi=1&version=3&playerapiid=ytplayer&rel=0", "white"]];

const beatsForDrumMachineArray = [["https://raw.githubusercontent.com/TazExprez/Logos/master/IMTrack1.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/IMTrack2.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/IMTrack3.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/IMTrack4.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/IMTrack5.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/IMTrack6.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/IMTrack7.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/IMTrack8.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/IMTrack9.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/IMFullTrack.mp3"],
                                  ["https://raw.githubusercontent.com/TazExprez/Logos/master/SLTrack1.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SLTrack2.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SLTrack3.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SLTrack4.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SLTrack5.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SLTrack6.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SLTrack7.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SLTrack8.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SLTrack9.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/SLFullTrack.mp3"],
                                  ["https://raw.githubusercontent.com/TazExprez/Logos/master/TDKTrack1.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/TDKTrack2.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/TDKTrack3.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/TDKTrack4.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/TDKTrack5.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/TDKTrack6.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/TDKTrack7.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/TDKTrack8.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/TDKTrack9.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/TDKFullTrack.mp3"],
                                  ["https://raw.githubusercontent.com/TazExprez/Logos/master/GTDTrack1.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/GTDTrack2.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/GTDTrack3.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/GTDTrack4.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/GTDTrack5.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/GTDTrack6.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/GTDTrack7.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/GTDTrack8.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/GTDTrack9.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/GTDFullTrack.mp3"]]

const generalSoundsForDrumMachineArray = ["https://raw.githubusercontent.com/TazExprez/Logos/master/Applause.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/DuckHuntDogLaugh.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/MichaelBufferLGRTR.mp3", "https://raw.githubusercontent.com/TazExprez/Logos/master/KWSPleaseDontGo.mp3"]

//Redux:

const VOLUME_LEVEL_LOWER = 'VOLUME_LEVEL_LOWER';

const VOLUME_LEVEL_HIGHER = 'VOLUME_LEVEL_HIGHER';

const SPECIFY_VOLUME_LEVEL = 'SPECIFY_VOLUME_LEVEL';

const VOLUME_LEVEL_DEFAULT = 70;

const EFFECTS_LEVEL = 'EFFECTS_LEVEL';

const EFFECTS_LEVEL_DEFAULT = "normal";

const SELECTED_THEME_AND_MUSIC_SLOT = 'SELECTED_THEME_AND_MUSIC_SLOT';

const DEFAULT_SELECTED_THEME_AND_MUSIC_SLOT = 0;

const setVolumeLevelLowerActionCreator = () => ({
  type: VOLUME_LEVEL_LOWER
});

const setVolumeLevelHigherActionCreator = () => ({
  type: VOLUME_LEVEL_HIGHER
});

const specifyVolumeLevelActionCreator = (specificVolumeLevel) => ({
  type: SPECIFY_VOLUME_LEVEL,
  volumeLevelChosen: specificVolumeLevel
});

const volumeLevelReducer = (state = VOLUME_LEVEL_DEFAULT, action) => {
  switch(action.type) {
    case VOLUME_LEVEL_LOWER:
      return state - 10;
    case VOLUME_LEVEL_HIGHER:
      return state + 10;
    case SPECIFY_VOLUME_LEVEL:
      return action.volumeLevelChosen;
    default:
      return state;
  }
};

//This action creator function gets the status of whether the sound effects are turned on.
const effectsLevelActionCreator = (effectsLevelSetting) => ({
  type: EFFECTS_LEVEL,
  currentEffectsLevel: effectsLevelSetting
});

//This reducer function returns the part of the state that deals with whether the sound effects are turned on.  The default value is false which means that the sound effects are not currently on.  The state being returned is a new state and not the original in altered form, unless the default case is executed.
  const effectsLevelReducer = (state = EFFECTS_LEVEL_DEFAULT, action) => {
  switch(action.type) {
    case EFFECTS_LEVEL:
      return action.currentEffectsLevel;
    default:
      return state;
  }
};

//This action creator function gets the directional change of the particular theme and music that will be selected.  The selectedThemeAndMusicSlotChange is the directional change that is chosen by the user.
const selectedThemeAndMusicSlotActionCreator = (themeAndMusicSlot) => ({
  type: SELECTED_THEME_AND_MUSIC_SLOT,
  selectedThemeAndMusicSlot: themeAndMusicSlot
});

//This reducer function returns the part of the state that deals with selecting a particular theme and music slot.  The default slot selected is the first, which is 0.  The state returned will be a new state and not the original, unless the default case is executed.
const selectedThemeAndMusicSlotReducer = (state = DEFAULT_SELECTED_THEME_AND_MUSIC_SLOT, action) => {
  switch(action.type) {
    case SELECTED_THEME_AND_MUSIC_SLOT:
      return action.selectedThemeAndMusicSlot;
    default:
      return state;
  }
};

//Here all of the different reducer functions are being combined into a single rootReducer function.
const rootReducer = Redux.combineReducers({
  volumeLevel: volumeLevelReducer,
  effectsLevel: effectsLevelReducer,
  themeAndMusicSlot: selectedThemeAndMusicSlotReducer
});

//Here you are creating the Redux store that will contain the state.
const store = Redux.createStore(rootReducer);

//React:

class DrumMachineComponent extends React.Component {
  constructor(props) {
    super(props);
  }
 
  render() {
    return(
      <div id="entire-drum-machine-component-div">
        {/*<WebAudioAPISoundEffectsComponent volumeLevel={this.props.reactReduxVolumeLevelState}/>*/}
        
        <ModalBoxesComponent themeAndMusicSlot={this.props.reactReduxThemeAndMusicSlotState} volumeLevel={this.props.reactReduxVolumeLevelState}/>
       
        <div id="drum-machine-and-outer-controller" tabIndex="0">
          <ThemeAndMusicPickerComponent themeAndMusicSlot={this.props.reactReduxThemeAndMusicSlotState} changeThemeAndMusicSlot={this.props.reactReduxChangeThemeAndMusicSlot} volumeLevel={this.props.reactReduxVolumeLevelState}/>
     
          <DrumPadsAndDisplayComponent themeAndMusicSlot={this.props.reactReduxThemeAndMusicSlotState} setCurrentEffectsLevel={this.props.reactReduxSpecifyEffectsLevel} volumeLevel={this.props.reactReduxVolumeLevelState} setVolumeLower={this.props.reactReduxSetVolumeLevelLower} setVolumeHigher={this.props.reactReduxSetVolumeLevelHigher} specifyVolumeLevel={this.props.reactReduxSpecifyVolumeLevel}/>
        </div>
      </div>
    );
  }
};

class ThreeWayToggleSwitchComponent extends React.Component {
  constructor(props) {
    super(props);
    
    this.state = {
      selectedOption: "Option 1",
      slidingButtonPosition: "left"
    };
    
    this.handleOptionChange = this.handleOptionChange.bind(this);
  }
  
  handleOptionChange(event) {
    if (event.target.value === "Option 1") {
      if (this.state.slidingButtonPosition === "middle") {
        this.setState({
          selectedOption: event.target.value,
          slidingButtonPosition: "left"
        });
        
        document.getElementById("leave-more-effects").play();
        document.getElementById("sliding-button-div").style.transform = "translate(0px)";
        document.getElementById("sliding-button-div").style.background = "green";
        
      }
      else if (this.state.slidingButtonPosition === "right") {
        this.setState({
          selectedOption: "Option 2",
          slidingButtonPosition: "middle"
        });
      
        document.getElementById("leave-extreme-effects").play();
        document.getElementById("sliding-button-div").style.transform = "translate(40px)";
        document.getElementById("sliding-button-div").style.background = "yellow";
      }
    }
    else if (event.target.value === "Option 2") {
      if (this.state.slidingButtonPosition === "left") {
        document.getElementById("go-to-more-effects").play();
      }
      else if (this.state.slidingButtonPosition === "right") {
        document.getElementById("leave-extreme-effects").play();
      }
      
      this.setState({
        selectedOption: "Option 2",
        slidingButtonPosition: "middle"
      });
      
      document.getElementById("sliding-button-div").style.transform = "translate(40px)";
      document.getElementById("sliding-button-div").style.background = "yellow";
    }
    else if (event.target.value === "Option 3") {
      if (this.state.slidingButtonPosition === "left") {
        this.setState({
          selectedOption: "Option 2",
          slidingButtonPosition: "middle"
        });
      
        document.getElementById("go-to-more-effects").play();
        document.getElementById("sliding-button-div").style.transform = "translate(40px)";
        document.getElementById("sliding-button-div").style.background = "yellow";
      }
      else if (this.state.slidingButtonPosition === "middle") {
        this.setState({
          selectedOption: "Option 3",
          slidingButtonPosition: "right"
        });
        
        document.getElementById("go-to-extreme-effects").play();
        document.getElementById("sliding-button-div").style.transform = "translate(80px)";
        document.getElementById("sliding-button-div").style.background = "red";
      }
    }
  }
  
  render() {    
    return(
      <div id="three-way-toggle-switch-component-div">
        <div id="radio-buttons-and-sliding-button-container-div">
          <div id="radio-buttons-div">
            <label id="option-1-label" className="single-option-label" for="option-1">Label 1
              <input type="radio" id="option-1" className="radio-input-class" name="radio-input" value="Option 1" checked={this.state.selectedOption === "Option 1"} onChange={this.handleOptionChange}/>
            </label>
            
            <label id="option-2-label" className="single-option-label" for="option-2">Label 2
              <input type="radio" id="option-2" className="radio-input-class" name="radio-input" value="Option 2" checked={this.state.selectedOption === "Option 2"} onChange={this.handleOptionChange}/>
            </label>
            
            <label id="option-3-label" className="single-option-label" for="option-3">Label 3
              <input type="radio" id="option-3" className="radio-input-class" name="radio-input" value="Option 3" checked={this.state.selectedOption === "Option 3"} onChange={this.handleOptionChange}/>
            </label>
          </div>
          
          <div id="sliding-button-div">
          </div>
        </div>
        
        <audio id="go-to-more-effects" class="effects-setting" src={generalSoundsForDrumMachineArray[0]} type="audio/mpeg" crossOrigin="anonymous">
        </audio>
        
        <audio id="leave-more-effects" class="effects-setting" src={generalSoundsForDrumMachineArray[1]} type="audio/mpeg" crossOrigin="anonymous">
        </audio>
        
        <audio id="go-to-extreme-effects" class="effects-setting" src={generalSoundsForDrumMachineArray[2]} type="audio/mpeg" crossOrigin="anonymous">
        </audio>
        
        <audio id="leave-extreme-effects" class="effects-setting" src={generalSoundsForDrumMachineArray[3]} type="audio/mpeg" crossOrigin="anonymous">
        </audio>
        
        <div id="selected-option">Option Selected: {this.state.selectedOption}
        </div>
        
        <div id="button-position">Button Position: {this.state.slidingButtonPosition}
        </div>
      </div>
    );
  }
};

class WebAudioAPISoundEffectsComponent extends React.Component {
  constructor(props) {
    super(props);
    setTimeout(() => {
      this.AudioContext = window.AudioContext || window.webkitAudioContext;
      this.audioContext = new this.AudioContext();
      
      this.leftArrowButtonAudioElement = document.getElementById("left-arrow-sound");
      this.leftArrowButtonTrack = this.audioContext.createMediaElementSource(this.leftArrowButtonAudioElement);
      this.leftArrowButtonTrackPlayButton = document.getElementById("left-arrow");
      this.leftArrowButtonTrackGainNode = this.audioContext.createGain();
      
      this.rightArrowButtonAudioElement = document.getElementById("right-arrow-sound");
      this.rightArrowButtonTrack = this.audioContext.createMediaElementSource(this.rightArrowButtonAudioElement);
      this.rightArrowButtonTrackPlayButton = document.getElementById("right-arrow");
      this.rightArrowButtonTrackGainNode = this.audioContext.createGain();
      
      this.moviePhraseAudioElement = document.getElementById("movie-phrase");
      this.moviePhraseTrack = this.audioContext.createMediaElementSource(this.moviePhraseAudioElement);
      this.moviePhraseTrackGainNode = this.audioContext.createGain();
      
      this.qButtonAudioElement = document.getElementById("Q");
      this.qButtonTrack = this.audioContext.createMediaElementSource(this.qButtonAudioElement);
      this.qButtonTrackPlayButton = document.getElementById("q-button");
      this.qButtonTrackGainNode = this.audioContext.createGain();
      
      this.wButtonAudioElement = document.getElementById("W");
      this.wButtonTrack = this.audioContext.createMediaElementSource(this.wButtonAudioElement);
      this.wButtonTrackPlayButton = document.getElementById("w-button");
      this.wButtonTrackGainNode = this.audioContext.createGain();
      
      this.eButtonAudioElement = document.getElementById("E");
      this.eButtonTrack = this.audioContext.createMediaElementSource(this.eButtonAudioElement);
      this.eButtonTrackPlayButton = document.getElementById("e-button");
      this.eButtonTrackGainNode = this.audioContext.createGain();
      
      this.aButtonAudioElement = document.getElementById("A");
      this.aButtonTrack = this.audioContext.createMediaElementSource(this.aButtonAudioElement);
      this.aButtonTrackPlayButton = document.getElementById("a-button");
      this.aButtonTrackGainNode = this.audioContext.createGain();
      
      this.sButtonAudioElement = document.getElementById("S");
      this.sButtonTrack = this.audioContext.createMediaElementSource(this.sButtonAudioElement);
      this.sButtonTrackPlayButton = document.getElementById("s-button");
      this.sButtonTrackGainNode = this.audioContext.createGain();
      
      this.dButtonAudioElement = document.getElementById("D");
      this.dButtonTrack = this.audioContext.createMediaElementSource(this.dButtonAudioElement);
      this.dButtonTrackPlayButton = document.getElementById("d-button");
      this.dButtonTrackGainNode = this.audioContext.createGain();
      
      this.zButtonAudioElement = document.getElementById("Z");
      this.zButtonTrack = this.audioContext.createMediaElementSource(this.zButtonAudioElement);
      this.zButtonTrackPlayButton = document.getElementById("z-button");
      this.zButtonTrackGainNode = this.audioContext.createGain();
      
      this.xButtonAudioElement = document.getElementById("X");
      this.xButtonTrack = this.audioContext.createMediaElementSource(this.xButtonAudioElement);
      this.xButtonTrackPlayButton = document.getElementById("x-button");
      this.xButtonTrackGainNode = this.audioContext.createGain();
      
      this.cButtonAudioElement = document.getElementById("C");
      this.cButtonTrack = this.audioContext.createMediaElementSource(this.cButtonAudioElement);
      this.cButtonTrackPlayButton = document.getElementById("c-button");
      this.cButtonTrackGainNode = this.audioContext.createGain();
      
      this.fullTrackButtonAudioElement = document.getElementById("F");
      this.fullTrackButtonTrack = this.audioContext.createMediaElementSource(this.fullTrackButtonAudioElement);
      this.fullTrackButtonPlayButton = document.getElementById("full-track");
      this.fullTrackButtonGainNode = this.audioContext.createGain();
      
      this.leftArrowButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.rightArrowButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.moviePhraseTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.qButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.wButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.eButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.aButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.sButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.dButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.zButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.xButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.cButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.fullTrackButtonGainNode.gain.value = this.props.volumeLevel * 0.01;
      
      this.leftArrowButtonTrack.connect(this.leftArrowButtonTrackGainNode).connect(this.audioContext.destination);
      this.rightArrowButtonTrack.connect(this.rightArrowButtonTrackGainNode).connect(this.audioContext.destination);
      this.moviePhraseTrack.connect(this.moviePhraseTrackGainNode).connect(this.audioContext.destination);
      this.qButtonTrack.connect(this.qButtonTrackGainNode).connect(this.audioContext.destination);
      this.wButtonTrack.connect(this.wButtonTrackGainNode).connect(this.audioContext.destination);
      this.eButtonTrack.connect(this.eButtonTrackGainNode).connect(this.audioContext.destination);
      this.aButtonTrack.connect(this.aButtonTrackGainNode).connect(this.audioContext.destination);
      this.sButtonTrack.connect(this.sButtonTrackGainNode).connect(this.audioContext.destination);
      this.dButtonTrack.connect(this.dButtonTrackGainNode).connect(this.audioContext.destination);
      this.zButtonTrack.connect(this.zButtonTrackGainNode).connect(this.audioContext.destination);
      this.xButtonTrack.connect(this.xButtonTrackGainNode).connect(this.audioContext.destination);
      this.cButtonTrack.connect(this.cButtonTrackGainNode).connect(this.audioContext.destination);
      this.fullTrackButtonTrack.connect(this.fullTrackButtonGainNode).connect(this.audioContext.destination); 
    }, 5);
    
    this.state = {
      leftArrowButtonTrackPlaying: false,
      rightArrowButtonTrackPlaying: false,
      moviePhraseTrackPlaying: false,
      qButtonTrackPlaying: false,
      wButtonTrackPlaying: false,
      eButtonTrackPlaying: false,
      aButtonTrackPlaying: false,
      sButtonTrackPlaying: false,
      dButtonTrackPlaying: false,
      zButtonTrackPlaying: false,
      xButtonTrackPlaying: false,
      cButtonTrackPlaying: false,
      fullTrackButtonTrackPlaying: false,
      currentVolume: 1
    };

    this.playLeftArrowButtonTrack = this.playLeftArrowButtonTrack.bind(this);
    this.playRightArrowButtonTrack = this.playRightArrowButtonTrack.bind(this);
    this.playQButtonTrack = this.playQButtonTrack.bind(this);
    this.playWButtonTrack = this.playWButtonTrack.bind(this);
    this.playEButtonTrack = this.playEButtonTrack.bind(this);
    this.playAButtonTrack = this.playAButtonTrack.bind(this);
    this.playSButtonTrack = this.playSButtonTrack.bind(this);
    this.playDButtonTrack = this.playDButtonTrack.bind(this);
    this.playZButtonTrack = this.playZButtonTrack.bind(this);
    this.playXButtonTrack = this.playXButtonTrack.bind(this);
    this.playCButtonTrack = this.playCButtonTrack.bind(this);
    this.playFullTrackButtonTrack = this.playFullTrackButtonTrack.bind(this);
    
    this.leftArrowButtonTrackOver = this.leftArrowButtonTrackOver.bind(this);
    this.rightArrowButtonTrackOver = this.rightArrowButtonTrackOver.bind(this);
    this.moviePhraseTrackOver = this.moviePhraseTrackOver.bind(this);
    this.qButtonTrackOver = this.qButtonTrackOver.bind(this);
    this.wButtonTrackOver = this.wButtonTrackOver.bind(this);
    this.eButtonTrackOver = this.eButtonTrackOver.bind(this);
    this.aButtonTrackOver = this.aButtonTrackOver.bind(this);
    this.sButtonTrackOver = this.sButtonTrackOver.bind(this);
    this.dButtonTrackOver = this.dButtonTrackOver.bind(this);
    this.zButtonTrackOver = this.zButtonTrackOver.bind(this);
    this.xButtonTrackOver = this.xButtonTrackOver.bind(this);
    this.cButtonTrackOver = this.cButtonTrackOver.bind(this);
    this.fullTrackButtonTrackOver= this.fullTrackButtonTrackOver.bind(this);
    
    this.changeVolumeLevel = this.changeVolumeLevel.bind(this);
    
    this.setEventListeners = this.setEventListeners.bind(this);
  }
  
  setEventListeners() {
    document.getElementById("drum-machine").addEventListener("touchmove", this.changeVolumeLevel);
    document.getElementById("drum-machine").addEventListener("click", this.changeVolumeLevel);
    
    document.getElementById("left-arrow").addEventListener("touchmove", this.playLeftArrowButtonTrack);
    document.getElementById("left-arrow").addEventListener("click", this.playLeftArrowButtonTrack);
    document.getElementById("left-arrow-sound").addEventListener("ended", this.leftArrowButtonTrackOver);
    
    document.getElementById("right-arrow").addEventListener("touchmove", this.playRightArrowButtonTrack);
    document.getElementById("right-arrow").addEventListener("click", this.playRightArrowButtonTrack);
    document.getElementById("right-arrow-sound").addEventListener("ended", this.rightArrowButtonTrackOver);
    
    document.getElementById("q-button").addEventListener("touchmove", this.playQButtonTrack);
    document.getElementById("q-button").addEventListener("click", this.playQButtonTrack);
    document.getElementById("Q").addEventListener("ended", this.qButtonTrackOver);
    
    document.getElementById("w-button").addEventListener("touchmove", this.playWButtonTrack);
    document.getElementById("w-button").addEventListener("click", this.playWButtonTrack);
    document.getElementById("W").addEventListener("ended", this.wButtonTrackOver);
    
    document.getElementById("e-button").addEventListener("touchmove", this.playEButtonTrack);
    document.getElementById("e-button").addEventListener("click", this.playEButtonTrack);
    document.getElementById("E").addEventListener("ended", this.eButtonTrackOver);
    
    document.getElementById("a-button").addEventListener("touchmove", this.playAButtonTrack);
    document.getElementById("a-button").addEventListener("click", this.playAButtonTrack);
    document.getElementById("A").addEventListener("ended", this.aButtonTrackOver);
    
    document.getElementById("s-button").addEventListener("touchmove", this.playSButtonTrack);
    document.getElementById("s-button").addEventListener("click", this.playSButtonTrack);
    document.getElementById("S").addEventListener("ended", this.sButtonTrackOver);
    
    document.getElementById("d-button").addEventListener("touchmove", this.playDButtonTrack);
    document.getElementById("d-button").addEventListener("click", this.playDButtonTrack);
    document.getElementById("D").addEventListener("ended", this.dButtonTrackOver);
    
    document.getElementById("z-button").addEventListener("touchmove", this.playZButtonTrack);
    document.getElementById("z-button").addEventListener("click", this.playZButtonTrack);
    document.getElementById("Z").addEventListener("ended", this.zButtonTrackOver);
    
    document.getElementById("x-button").addEventListener("touchmove", this.playXButtonTrack);
    document.getElementById("x-button").addEventListener("click", this.playXButtonTrack);
    document.getElementById("X").addEventListener("ended", this.xButtonTrackOver);
    
    document.getElementById("c-button").addEventListener("touchmove", this.playCButtonTrack);
    document.getElementById("c-button").addEventListener("click", this.playCButtonTrack);
    document.getElementById("C").addEventListener("ended", this.cButtonTrackOver);
    
    document.getElementById("full-track").addEventListener("touchmove", this.playFullTrackButtonTrack);
    document.getElementById("full-track").addEventListener("click", this.playFullTrackButtonTrack);
    document.getElementById("F").addEventListener("ended", this.fullTrackButtonTrackOver);
  }
  
  playLeftArrowButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.leftArrowButtonTrackPlaying === false) {
        this.leftArrowButtonAudioElement.play();
        
        setTimeout(() => {
          this.moviePhraseAudioElement.play();  
        }, 800);
        
        this.setState({
          leftArrowButtonTrackPlaying: true
        });
      }
      else if (this.state.leftArrowButtonTrackPlaying === true) {
        this.leftArrowButtonAudioElement.pause();
      
        this.setState({
          leftArrowButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playRightArrowButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.rightArrowButtonTrackPlaying === false) {
        this.rightArrowButtonAudioElement.play();
      
        setTimeout(() => {
          this.moviePhraseAudioElement.play();  
        }, 800);
        
        this.setState({
          rightArrowButtonTrackPlaying: true
        });
      }
      else if (this.state.rightArrowButtonTrackPlaying === true) {
        this.rightArrowButtonAudioElement.pause();
      
        this.setState({
          rightArrowButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playQButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.qButtonTrackPlaying === false) {
        this.qButtonAudioElement.play();
        
        this.setState({
          qButtonTrackPlaying: true
        });
      }
      else if (this.state.qButtonTrackPlaying === true) {
        this.qButtonAudioElement.pause();
      
        this.setState({
          qButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playWButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.wButtonTrackPlaying === false) {
        this.wButtonAudioElement.play();
      
        this.setState({
          wButtonTrackPlaying: true
        });
      }
      else if (this.state.wButtonTrackPlaying === true) {
        this.wButtonAudioElement.pause();
      
        this.setState({
          wButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playEButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.eButtonTrackPlaying === false) {
        this.eButtonAudioElement.play();
      
        this.setState({
          eButtonTrackPlaying: true
        });
      }
      else if (this.state.eButtonTrackPlaying === true) {
        this.eButtonAudioElement.pause();
      
        this.setState({
          eButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playAButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.aButtonTrackPlaying === false) {
        this.aButtonAudioElement.play();
      
        this.setState({
          aButtonTrackPlaying: true
        });
      }
      else if (this.state.aButtonTrackPlaying === true) {
        this.aButtonAudioElement.pause();
      
        this.setState({
          aButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playSButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.sButtonTrackPlaying === false) {
        this.sButtonAudioElement.play();
      
        this.setState({
          sButtonTrackPlaying: true
        });
      }
      else if (this.state.sButtonTrackPlaying === true) {
        this.sButtonAudioElement.pause();
      
        this.setState({
          sButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playDButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.dButtonTrackPlaying === false) {
        this.dButtonAudioElement.play();
      
        this.setState({
          dButtonTrackPlaying: true
        });
      }
      else if (this.state.dButtonTrackPlaying === true) {
        this.dButtonAudioElement.pause();
      
        this.setState({
          dButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playZButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.zButtonTrackPlaying === false) {
        this.zButtonAudioElement.play();
      
        this.setState({
          zButtonTrackPlaying: true
        });
      }
      else if (this.state.zButtonTrackPlaying === true) {
        this.zButtonAudioElement.pause();
      
        this.setState({
          zButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playXButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.xButtonTrackPlaying === false) {
        this.xButtonAudioElement.play();
      
        this.setState({
          xButtonTrackPlaying: true
        });
      }
      else if (this.state.xButtonTrackPlaying === true) {
        this.xButtonAudioElement.pause();
      
        this.setState({
          xButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playCButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.cButtonTrackPlaying === false) {
        this.cButtonAudioElement.play();
      
        this.setState({
          cButtonTrackPlaying: true
        });
      }
      else if (this.state.cButtonTrackPlaying === true) {
        this.cButtonAudioElement.pause();
      
        this.setState({
          cButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  playFullTrackButtonTrack() {
    setTimeout(() => {
      // check if context is in suspended state (autoplay policy)
      if (this.audioContext.state === 'suspended') {
        this.audioContext.resume();
      }

      // play or pause track depending on state
      if (this.state.fullTrackButtonTrackPlaying === false) {
        this.fullTrackButtonAudioElement.play();
      
        this.setState({
          fullTrackButtonTrackPlaying: true
        });
      }
      else if (this.state.fullTrackButtonTrackPlaying === true) {
        this.fullTrackButtonAudioElement.pause();
      
        this.setState({
          fullTrackButtonTrackPlaying: false
        });
      }
    },1);
  }
  
  leftArrowButtonTrackOver() {
    this.setState({
      leftArrowButtonTrackPlaying: false
    });
  }
  
  rightArrowButtonTrackOver() {
    this.setState({
      rightArrowButtonTrackPlaying: false
    });
  }
  
  moviePhraseTrackOver() {
    this.setState({
      moviePhraseTrackPlaying: false
    });
  }
  
  qButtonTrackOver() {
    this.setState({
      qButtonTrackPlaying: false
    });
  }
  
  wButtonTrackOver() {
    this.setState({
      wButtonTrackPlaying: false
    });
  }
  
  eButtonTrackOver() {
    this.setState({
      eButtonTrackPlaying: false
    });
  }
  
  aButtonTrackOver() {
    this.setState({
      aButtonTrackPlaying: false
    });
  }
  
  sButtonTrackOver() {
    this.setState({
      sButtonTrackPlaying: false
    });
  }
  
  dButtonTrackOver() {
    this.setState({
      dButtonTrackPlaying: false
    });
  }
  
  zButtonTrackOver() {
    this.setState({
      zButtonTrackPlaying: false
    });
  }
  
  xButtonTrackOver() {
    this.setState({
      xButtonTrackPlaying: false
    });
  }
  
  cButtonTrackOver() {
    this.setState({
      cButtonTrackPlaying: false
    });
  }
  
  fullTrackButtonTrackOver() {
    this.setState({
      fullTrackButtonTrackPlaying: false
    });
  }
  
  changeVolumeLevel() {
    setTimeout(() => {
      //I had to assign a value to each gain node individually, instead of using a single constant node offset, because iOS does not support the ConstantSourceNode API.
      this.leftArrowButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.rightArrowButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.moviePhraseTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.qButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.wButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.eButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.aButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.sButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.dButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.zButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.xButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.cButtonTrackGainNode.gain.value = this.props.volumeLevel * 0.01;
      this.fullTrackButtonGainNode.gain.value = this.props.volumeLevel * 0.01;
    }, 1);
  }
  
  componentDidMount() {
    this.setEventListeners();
  }
  
  render() {
    return(
      <div> 
      </div>
    );
  }
}

class ModalBoxesComponent extends React.Component {
  constructor(props) {
    super(props);
    
    this.stopYoutubeVideo = this.stopYoutubeVideo.bind(this);
    this.closeYoutubeVideoModalDiv = this.closeYoutubeVideoModalDiv.bind(this);
  }
 
  stopYoutubeVideo() {
    let iframes = document.querySelectorAll('iframe');
   
    Array.prototype.forEach.call(iframes, iframe => {
      iframe.contentWindow.postMessage(JSON.stringify({event: 'command',
      func: 'stopVideo' }), '*');
    });
  }
       
  closeYoutubeVideoModalDiv() {
    document.documentElement.style.setProperty("--show-modal-div", "none");
    document.documentElement.style.setProperty("--show-youtube-video-div", "none");
   
    this.stopYoutubeVideo();
  }
 
  render() {
    return(
      <div id="modal-div">
        <div id="help-div">
       
        </div>
       
        <div id="youtube-video-div">
          <div id="close-youtube-video-span-div-container-div">
            <div id="close-youtube-video-span-div">
              <span id="close-youtube-video-span" onClick={this.closeYoutubeVideoModalDiv}>&times;</span>
            </div>
          </div>

          <iframe id="youtube-video-iframe" width="560" height="315" src={themesForDrumMachineArray[this.props.themeAndMusicSlot][10]} frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="true" allowscriptaccess="always"></iframe>
        </div>
      </div>
    );
  }
}

class VolumeKnobComponent extends React.Component {
  constructor(props) {
    super(props);
    
    this.scrollWheelRef = React.createRef();
    
    this.allAudioElements = document.getElementsByTagName('audio');
    
    this.interactionArea = document.getElementById("interaction-area");
    this.width = 100;
    this.height = 100;
    this.touchPosX = 0;
    this.touchPosY = this.height / 2;
    this.currentAngle = 0;  
  
    this.setTouchPos = this.setTouchPos.bind(this);
    this.calculateAngle = this.calculateAngle.bind(this);
    this.setEventListeners = this.setEventListeners.bind(this);
    this.setDefaultVolumeLevel = this.setDefaultVolumeLevel.bind(this);
  }
  
  setDefaultVolumeLevel() {
    this.scrollWheelRef.current.style.transform = 'rotate('+ 45 +'deg)';
  }
  
  setEventListeners() {
    document.getElementById("interaction-area").addEventListener("touchmove", this.calculateAngle);
    document.getElementById("interaction-area").addEventListener("touchstart", this.setTouchPos);

    document.getElementById("interaction-area").addEventListener("mousedown", this.setTouchPos);
    document.getElementById("interaction-area").addEventListener("mousemove", this.calculateAngle);
  }
    
  setTouchPos(event) {
    this.touchPosX = event.layerX - (this.width / 2);
    this.touchPosY = (this.height / 2) - event.layerY;
  }

  calculateAngle(event) {
    let adjustedLayerX = event.layerX - (this.width / 2);
    let adjustedLayerY = (this.height / 2) - event.layerY;
  
    let startAngle = Math.atan2(this.touchPosY, this.touchPosX) * 180 / Math.PI - 90;
    let deltaAngle = Math.atan2(adjustedLayerY, adjustedLayerX) * 180 / Math.PI - 90;
    
    this.currentAngle += (startAngle-deltaAngle);
  
    switch(true) {
      case this.currentAngle > 150 && this.currentAngle <= 210:
        this.props.specifyVolumeLevel(0);
        setTimeout(() => {
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);}, 5);
        break;
      case this.currentAngle > 210 && this.currentAngle <= 240:
        this.props.specifyVolumeLevel(10);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
      case (this.currentAngle > 240 && this.currentAngle <= 269) || this.currentAngle === -90:
        this.props.specifyVolumeLevel(20);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
      case this.currentAngle > -90 && this.currentAngle <= -60:
        this.props.specifyVolumeLevel(30);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
      case this.currentAngle > -60 && this.currentAngle <= -30:
        this.props.specifyVolumeLevel(40);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
      case this.currentAngle > -30 && this.currentAngle < 0:
        this.props.specifyVolumeLevel(50);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
      case this.currentAngle > 0 && this.currentAngle <= 30:
        this.props.specifyVolumeLevel(60);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
      case this.currentAngle > 30 && this.currentAngle <= 60:
        this.props.specifyVolumeLevel(70);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
      case this.currentAngle > 60 && this.currentAngle <= 90:
        this.props.specifyVolumeLevel(80);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
      case this.currentAngle > 90 && this.currentAngle <= 120:
        this.props.specifyVolumeLevel(90);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
      case this.currentAngle > 120 && this.currentAngle <= 150:
        this.props.specifyVolumeLevel(100);
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
        break;
    }
  
    this.scrollWheelRef.current.style.transform = 'rotate('+ this.currentAngle +'deg)';
    
    if (!this.props.volumeLevel) {
      this.scrollWheelRef.current.style.background = "rgba(0, 0, 0, 0.2)";
    }
    else if (this.props.volumeLevel === 90) {
      this.scrollWheelRef.current.style.background = "rgba(255,255,0, 1.0)";
    }
    else if (this.props.volumeLevel === 100) {
      this.scrollWheelRef.current.style.background = "rgba(360, 0, 0, 1.0)";
    }
    else {
      this.scrollWheelRef.current.style.background = "rgba(0, 191, 255, " + this.props.volumeLevel * 0.0125 + ")";
    }
    
    this.touchPosX = adjustedLayerX;
    this.touchPosY = adjustedLayerY;
  }
  
  componentDidMount() {
    this.setDefaultVolumeLevel();
    
    //This prevents the iOS Safari bounce.
    document.getElementById("scroll-wheel-wrapper").addEventListener('touchmove', function( event ){ event.preventDefault() });
  }
  
  render() {
    return(
      <div>
        <div id="scroll-wheel-wrapper">
          <div id="scroll-wheel" ref={this.scrollWheelRef}>
            <div id="thumb">
            </div>
          </div>
          
          <div id="interaction-area" onMouseMove={this.setEventListeners} onTouchMove={this.setEventListeners}>
          </div>
        </div>
      </div>
    );
  }
};

class ThemeAndMusicPickerComponent extends React.Component {
  constructor(props) {
    super(props);
    
    this.allAudioTracks = document.getElementsByTagName('audio');
    
    this.state = {
      appleSpecialMode: false
    };
    
    this.moveToPreviousThemeAndMusic = this.moveToPreviousThemeAndMusic.bind(this);
    this.moveToNextThemeAndMusic = this.moveToNextThemeAndMusic.bind(this);
  }
  
  moveToPreviousThemeAndMusic() {
    setTimeout(() => {
      document.getElementById('left-arrow-sound').volume = this.props.volumeLevel * 0.01;
      document.getElementById('left-arrow-sound').play();
    }, 5);
   
    setTimeout(() => {
      let newSlotPosition = this.props.themeAndMusicSlot;
   
      if (this.props.themeAndMusicSlot === 0) {
        newSlotPosition = themesForDrumMachineArray.length - 1;
      }
      else {
        newSlotPosition -= 1;
      }
   
      this.props.changeThemeAndMusicSlot(newSlotPosition);
   
      document.documentElement.style.setProperty("--left-arrow-color", themesForDrumMachineArray[newSlotPosition][1]);
      document.documentElement.style.setProperty("--left-arrow-hover-color", themesForDrumMachineArray[newSlotPosition][2]);
      document.documentElement.style.setProperty("--right-arrow-color", themesForDrumMachineArray[newSlotPosition][3]);
      document.documentElement.style.setProperty("--right-arrow-hover-color", themesForDrumMachineArray[newSlotPosition][4]);
      document.documentElement.style.setProperty("--image-border-color", themesForDrumMachineArray[newSlotPosition][5]);
      document.documentElement.style.setProperty("--body-background-color", themesForDrumMachineArray[newSlotPosition][6]);
      document.documentElement.style.setProperty("--font-family", themesForDrumMachineArray[newSlotPosition][7]);
      document.documentElement.style.setProperty("--youtube-video-div-background-color", themesForDrumMachineArray[newSlotPosition][11]);
    }, 400);
   
    setTimeout(() => {
      document.getElementById('movie-phrase').volume = this.props.volumeLevel * 0.01;
      document.getElementById('movie-phrase').play();
    }, 800);
  }
 
  moveToNextThemeAndMusic() {
    setTimeout(() => {
      document.getElementById('right-arrow-sound').volume = this.props.volumeLevel * 0.01;
      document.getElementById('right-arrow-sound').play();
    }, 5);
   
    setTimeout(() => {
      let newSlotPosition = this.props.themeAndMusicSlot;
   
      if (this.props.themeAndMusicSlot === themesForDrumMachineArray.length - 1) {
        newSlotPosition = 0;
      }
      else {
        newSlotPosition += 1;
      }
   
      this.props.changeThemeAndMusicSlot(newSlotPosition);
     
      document.documentElement.style.setProperty("--left-arrow-color", themesForDrumMachineArray[newSlotPosition][1]);
      document.documentElement.style.setProperty("--left-arrow-hover-color", themesForDrumMachineArray[newSlotPosition][2]);
      document.documentElement.style.setProperty("--right-arrow-color", themesForDrumMachineArray[newSlotPosition][3]);
      document.documentElement.style.setProperty("--right-arrow-hover-color", themesForDrumMachineArray[newSlotPosition][4]);
      document.documentElement.style.setProperty("--image-border-color", themesForDrumMachineArray[newSlotPosition][5]);
      document.documentElement.style.setProperty("--body-background-color", themesForDrumMachineArray[newSlotPosition][6]);
      document.documentElement.style.setProperty("--font-family", themesForDrumMachineArray[newSlotPosition][7]);
      document.documentElement.style.setProperty("--youtube-video-div-background-color", themesForDrumMachineArray[newSlotPosition][11]);
    }, 400);
   
    setTimeout(() => {
      document.getElementById('movie-phrase').volume = this.props.volumeLevel * 0.01;
      document.getElementById('movie-phrase').play();
    }, 800);
  }
  
  render() {
    return(
      <div id="theme-and-music-picker" tabIndex="0">
        <i id="left-arrow" class="fas fa-chevron-left theme-and-music-picker-arrows" onClick={this.moveToPreviousThemeAndMusic}>
          <audio id="left-arrow-sound" class="arrow-sound" src={themesForDrumMachineArray[this.props.themeAndMusicSlot][8]} type="audio/mpeg" crossOrigin="anonymous">
          </audio>
        </i>
       
        <img id="movie-banner" src={themesForDrumMachineArray[this.props.themeAndMusicSlot][0]}/>
       
        <i id="right-arrow" class="fas fa-chevron-right theme-and-music-picker-arrows" onClick={this.moveToNextThemeAndMusic}>
          <audio id="right-arrow-sound" class="arrow-sound" src={themesForDrumMachineArray[this.props.themeAndMusicSlot][8]} type="audio/mpeg" crossOrigin="anonymous">
          </audio>
        </i>
       
        <audio id="movie-phrase" src={themesForDrumMachineArray[this.props.themeAndMusicSlot][9]} type="audio/mpeg" crossOrigin="anonymous">
        </audio>
      </div>
    );
  }
};

class DrumPadsAndDisplayComponent extends React.Component {
  constructor(props) {
    super(props);
    
    this.drumMachineRef = React.createRef();
    
    this.allAudioTracks = document.getElementsByTagName('audio');
    
    this.state = {
      qButtonTrackPlaying: false,
      wButtonTrackPlaying: false,
      eButtonTrackPlaying: false,
      aButtonTrackPlaying: false,
      sButtonTrackPlaying: false,
      dButtonTrackPlaying: false,
      zButtonTrackPlaying: false,
      xButtonTrackPlaying: false,
      cButtonTrackPlaying: false,
      fullTrackButtonTrackPlaying: false,
      displayText: ""
    }
    
    this.keyboardPress = this.keyboardPress.bind(this);
    this.pauseAllAudioTracks = this.pauseAllAudioTracks.bind(this);
    
    this.playDrumPad1 = this.playDrumPad1.bind(this);
    this.playDrumPad2 = this.playDrumPad2.bind(this);
    this.playDrumPad3 = this.playDrumPad3.bind(this);
    this.playDrumPad4 = this.playDrumPad4.bind(this);
    this.playDrumPad5 = this.playDrumPad5.bind(this);
    this.playDrumPad6 = this.playDrumPad6.bind(this);
    this.playDrumPad7 = this.playDrumPad7.bind(this);
    this.playDrumPad8 = this.playDrumPad8.bind(this);
    this.playDrumPad9 = this.playDrumPad9.bind(this);
    this.playFullTrack = this.playFullTrack.bind(this);
    
    this.qButtonTrackOver = this.qButtonTrackOver.bind(this);
    this.wButtonTrackOver = this.wButtonTrackOver.bind(this);
    this.eButtonTrackOver = this.eButtonTrackOver.bind(this);
    this.aButtonTrackOver = this.aButtonTrackOver.bind(this);
    this.sButtonTrackOver = this.sButtonTrackOver.bind(this);
    this.dButtonTrackOver = this.dButtonTrackOver.bind(this);
    this.zButtonTrackOver = this.zButtonTrackOver.bind(this);
    this.xButtonTrackOver = this.xButtonTrackOver.bind(this);
    this.cButtonTrackOver = this.cButtonTrackOver.bind(this);
    this.fullTrackButtonTrackOver= this.fullTrackButtonTrackOver.bind(this);
    
    this.openAndCloseYoutubeWithKeyboard = this.openAndCloseYoutubeWithKeyboard.bind(this);
    this.openYoutubeVideo = this.openYoutubeVideo.bind(this);
    
    this.setVolumeLower = this.setVolumeLower.bind(this);
    this.setVolumeHigher = this.setVolumeHigher.bind(this);
    this.moveVolumeKnob = this.moveVolumeKnob.bind(this);
    
    this.clickLeftArrow = this.clickLeftArrow.bind(this);
    this.clickRightArrow = this.clickRightArrow.bind(this);
    
    this.setEventListeners = this.setEventListeners.bind(this);
  }
  
  setEventListeners() {
    document.getElementById("Q").addEventListener("ended", this.qButtonTrackOver);
    document.getElementById("W").addEventListener("ended", this.wButtonTrackOver);
    document.getElementById("E").addEventListener("ended", this.eButtonTrackOver);
    document.getElementById("A").addEventListener("ended", this.aButtonTrackOver);
    document.getElementById("S").addEventListener("ended", this.sButtonTrackOver);
    document.getElementById("D").addEventListener("ended", this.dButtonTrackOver);
    document.getElementById("Z").addEventListener("ended", this.zButtonTrackOver);
    document.getElementById("X").addEventListener("ended", this.xButtonTrackOver);
    document.getElementById("C").addEventListener("ended", this.cButtonTrackOver);
    document.getElementById("F").addEventListener("ended", this.fullTrackButtonTrackOver);
  } 
  
  pauseAllAudioTracks() {
    Array.from(this.allAudioTracks).forEach(i => i.pause());
  }
  
  playDrumPad1() {
    if (!this.state.qButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('Q').play();
      
      this.setState({
        qButtonTrackPlaying: true,
        displayText: "Part 1"
      });
    }
    else {
      document.getElementById('Q').pause();
      
      this.setState({
        qButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  playDrumPad2() {
    if (!this.state.wButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('W').play();
      
      this.setState({
        wButtonTrackPlaying: true,
        displayText: "Part 2"
      });
    }
    else {
      document.getElementById('W').pause();
      
      this.setState({
        wButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  playDrumPad3() {
    if (!this.state.eButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('E').play();
      
      this.setState({
        eButtonTrackPlaying: true,
        displayText: "Part 3"
      });
    }
    else {
      document.getElementById('E').pause();
      
      this.setState({
        eButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  playDrumPad4() {
    if (!this.state.aButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('A').play();
      
      this.setState({
        aButtonTrackPlaying: true,
        displayText: "Part 4"
      });
    }
    else {
      document.getElementById('A').pause();
      
      this.setState({
        aButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  playDrumPad5() {
    if (!this.state.sButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('S').play();
      
      this.setState({
        sButtonTrackPlaying: true,
        displayText: "Part 5"
      });
    }
    else {
      document.getElementById('S').pause();
      
      this.setState({
        sButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  playDrumPad6() {
    if (!this.state.dButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('D').play();
      
      this.setState({
        dButtonTrackPlaying: true,
        displayText: "Part 6"
      });
    }
    else {
      document.getElementById('D').pause();
      
      this.setState({
        dButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  playDrumPad7() {
    if (!this.state.zButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('Z').play();
      
      this.setState({
        zButtonTrackPlaying: true,
        displayText: "Part 7"
      });
    }
    else {
      document.getElementById('Z').pause();
      
      this.setState({
        zButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  playDrumPad8() {
    if (!this.state.xButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('X').play();
      
      this.setState({
        xButtonTrackPlaying: true,
        displayText: "Part 8"
      });
    }
    else {
      document.getElementById('X').pause();
      
      this.setState({
        xButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  playDrumPad9() {
    if (!this.state.cButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('C').play();
      
      this.setState({
        cButtonTrackPlaying: true,
        displayText: "Part 9"
      });
    }
    else {
      document.getElementById('C').pause();
      
      this.setState({
        cButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  playFullTrack() {
    if (!this.state.fullTrackButtonTrackPlaying) {
      this.pauseAllAudioTracks();
    
      document.getElementById('F').play();
      
      this.setState({
        fullTrackButtonTrackPlaying: true,
        displayText: "Full Track"
      });
    }
    else {
      document.getElementById('F').pause();
      
      this.setState({
        fullTrackButtonTrackPlaying: false,
        displayText: ""
      });
    }
  }
 
  qButtonTrackOver() {
    this.setState({
      qButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
  wButtonTrackOver() {
    this.setState({
      wButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
  eButtonTrackOver() {
    this.setState({
      eButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
  aButtonTrackOver() {
    this.setState({
      aButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
  sButtonTrackOver() {
    this.setState({
      sButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
  dButtonTrackOver() {
    this.setState({
      dButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
 zButtonTrackOver() {
    this.setState({
      zButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
  xButtonTrackOver() {
    this.setState({
      xButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
  cButtonTrackOver() {
    this.setState({
      cButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
  fullTrackButtonTrackOver() {
    this.setState({
      fullTrackButtonTrackPlaying: false,
      displayText: ""
    });
  }
  
  openAndCloseYoutubeWithKeyboard() {
    if (!this.state.youtubeOpen) {
      document.documentElement.style.setProperty("--show-modal-div", "block");
      document.documentElement.style.setProperty("--show-youtube-video-div", "block");
     
      this.setState({
        youtubeOpen: true
      });
    }
    else {
      document.getElementById("close-youtube-video-span").click();
     
      this.setState({
        youtubeOpen: false
      });
    }
  }
 
  moveVolumeKnob() {
    setTimeout(() => {
      switch (this.props.volumeLevel) {
        case 0:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ 180 +'deg)';
          break;
        case 10:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ 225 +'deg)';
          break;
        case 20:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ 255 +'deg)';
          break;
        case 30:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ -75 +'deg)';
          break;
        case 40:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ -45 +'deg)';
          break;
        case 50:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ -15 +'deg)';
          break;
        case 60:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ 15 +'deg)';
          break;
        case 70:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ 45 +'deg)';
          break;
        case 80:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ 75 +'deg)';
          break;
        case 90:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ 105 +'deg)';
          break;
        case 100:
          document.getElementById("scroll-wheel").style.transform = 'rotate('+ 135 +'deg)';
          break;
      }
      
      if (!this.props.volumeLevel) {
        document.getElementById("scroll-wheel").style.background = "rgba(0, 0, 0, 0.2)";
      }
      else if (this.props.volumeLevel === 90) {
        document.getElementById("scroll-wheel").style.background = "rgba(255,255,0, 1.0)";
      }
      else if (this.props.volumeLevel === 100) {
        document.getElementById("scroll-wheel").style.background = "rgba(360, 0, 0, 1.0)";
      }
      else {
        document.getElementById("scroll-wheel").style.background = "rgba(0, 191, 255, " + this.props.volumeLevel * 0.0125 + ")";
      }
    }, 5);
  }
  
  setVolumeLower() {
    if (this.props.volumeLevel > 0) {
      this.props.setVolumeLower();
      this.moveVolumeKnob();
      setTimeout(() => {
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
      }, 5);
    }
  }
 
  setVolumeHigher() {
    if (this.props.volumeLevel < 100) {
      this.props.setVolumeHigher();
      this.moveVolumeKnob();
      setTimeout(() => {
        Array.from(this.allAudioElements).map(i => i.volume = this.props.volumeLevel * 0.01);
      }, 5);
    }
  }
  
  keyboardPress(event) {
    if (event.keyCode === 81) {
      this.playDrumPad1();
    }
    else if (event.keyCode === 87) {
      this.playDrumPad2();
    }
    else if (event.keyCode === 69) {
      this.playDrumPad3();
    }
     if (event.keyCode === 65) {
      this.playDrumPad4();
    }
    else if (event.keyCode === 83) {
      this.playDrumPad5();
    }
    else if (event.keyCode === 68) {
      this.playDrumPad6();
    }
     if (event.keyCode === 90) {
      this.playDrumPad7();
    }
    else if (event.keyCode === 88) {
      this.playDrumPad8();
    }
    else if (event.keyCode === 67) {
      this.playDrumPad9();
    }
    else if (event.keyCode === 70) {
      this.playFullTrack();
    }
    else if (event.keyCode === 89) {
      this.openAndCloseYoutubeWithKeyboard();
    }
    else if (event.keyCode === 40) {
      this.setVolumeLower();
    }
    else if (event.keyCode === 38) {
      this.setVolumeHigher();
    }
    else if (event.keyCode === 37) {
      this.clickLeftArrow();
    }
    else if (event.keyCode === 39) {
      this.clickRightArrow();
    }
  }
 
  openYoutubeVideo() {
    document.documentElement.style.setProperty("--show-modal-div", "block");
    document.documentElement.style.setProperty("--show-youtube-video-div", "block");
  }
  
  clickLeftArrow() {
    document.getElementById('left-arrow').click();
  }
 
  clickRightArrow() {
    document.getElementById('right-arrow').click();
  }
  
  componentDidMount() {
    this.setEventListeners();
    
    /*setTimeout(() => {
      this.drumMachineRef.current.focus();
    }, 5);*/
  }
  
  //This is the method that renders everything that will be displayed by the DrumPadsAndDisplayComponent in the application.  I had to use <span> elements for the letters on the drum pads because of a bug in iOS.  If I did not use <span> elements without any block rendering, then the linear-gradient text would not have worked with iOS.  You can read more about this issue here https://stackoverflow.com/questions/32084460/safari-doesnt-render-css-gradient-text at Stack Overflow.
  render() {
    return(
      <div id="drum-machine" tabIndex="0" ref={this.drumMachineRef} onKeyDown={this.keyboardPress}>
        <div id="all-other-buttons">
          <div id="display-and-non-drum-buttons">
            <div id="youtube-container-div">
              <button id="youtube-button" onClick={this.openYoutubeVideo}>
                <i id="youtube-icon" class="fab fa-youtube"></i>
              </button>
            </div>
         
            <div id="display">
              {this.state.displayText}
            </div>
         
            <div id="full-track-container-div">
              <button id="full-track" onClick={this.playFullTrack} data-playing="false" role="switch" aria-checked="false">
                <span id="full-track-span">Song</span>
             
                <audio id="F" class="clip" src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][9]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>  
          </div>
       
          <div id="volume-buttons-and-display">          
            <div id="volume-knob-component-container-div">
              <VolumeKnobComponent volumeLevel={this.props.volumeLevel} setVolumeLower={this.props.setVolumeLower} setLevelHigher={this.props.setVolumeHigher} specifyVolumeLevel={this.props.specifyVolumeLevel}/>
            </div>
       
            <div id="volume-display">
              {this.props.volumeLevel}
            </div>
            
            <ThreeWayToggleSwitchComponent volumeLevel={this.volumeLevel} setCurrentEffectsLevel={this.setCurrentEffectsLevel}/>
            
          </div>
        </div>
         
        <div id="all-drum-pads">
          <div id="drum-pads-row-1" class="drum-pads-row">
            <div id="q-div" class="drum-pad-container-div">
              <button id="q-button" class="drum-pad" onClick={this.playDrumPad1}>
                <span id="q-span" class="drum-pad-letter-span">Q</span>
               
                <audio id="Q" class="clip" src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][0]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>
           
            <div id="w-div" class="drum-pad-container-div">
              <button id="w-button" class="drum-pad" onClick={this.playDrumPad2}>
                <span id="w-span" class="drum-pad-letter-span">W</span>
               
                <audio id="W" class="clip" src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][1]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>
         
            <div id="e-div" class="drum-pad-container-div">
              <button id="e-button" class="drum-pad" onClick={this.playDrumPad3}>
                <span id="e-span" class="drum-pad-letter-span">E</span>
               
                <audio id="E" class="clip" src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][2]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>
          </div>
         
          <div id="drum-pads-row-2" class="drum-pads-row">
            <div id="a-div" class="drum-pad-container-div">
              <button id="a-button" class="drum-pad" onClick={this.playDrumPad4}>
                <span id="a-span" class="drum-pad-letter-span">A</span>
               
                <audio id="A" class="clip" src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][3]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>
         
            <div id="s-div" class="drum-pad-container-div">
              <button id="s-button" class="drum-pad" onClick={this.playDrumPad5}>
                <span id="s-span" class="drum-pad-letter-span">S</span>
               
                <audio id="S" class="clip"src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][4]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>
         
            <div id="d-div" class="drum-pad-container-div">
              <button id="d-button" class="drum-pad" onClick={this.playDrumPad6}>
                <span id="d-span" class="drum-pad-letter-span">D</span>
               
                <audio id="D" class="clip" src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][5]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>
          </div>
           
          <div id="drum-pads-row-3" class="drum-pads-row">
            <div id="z-div" class="drum-pad-container-div">
              <button id="z-button" class="drum-pad" onClick={this.playDrumPad7}>
                <span id="z-span" class="drum-pad-letter-span">Z</span>
               
                <audio id="Z" class="clip" src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][6]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>
         
            <div id="x-div" class="drum-pad-container-div">
              <button id="x-button" class="drum-pad" onClick={this.playDrumPad8}>
                <span id="x-span" class="drum-pad-letter-span">X</span>
               
                <audio id="X" class="clip" src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][7]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>
         
            <div id="c-div" class="drum-pad-container-div">
              <button id="c-button" class="drum-pad" onClick={this.playDrumPad9}>
                <span id="c-span" class="drum-pad-letter-span">C</span>
               
                <audio id="C" class="clip" src={beatsForDrumMachineArray[this.props.themeAndMusicSlot][8]} type="audio/mpeg" crossOrigin="anonymous">
                </audio>
              </button>
            </div>
          </div>
        </div>
      </div>
    );
  }
};

//React Redux:

//This Provider component will provide access to the Redux store.
const Provider = ReactRedux.Provider;

//This connect() will connect your React MarkdownPreviewerComponent component with the Redux store.
const connect = ReactRedux.connect;

//This will map the Redux state that you want to pass as props to the MarkdownPreviewerComponent component.
const mapStateToProps = (reduxState) => ({
  reactReduxVolumeLevelState: reduxState.volumeLevel,
  reactReduxEffectsLevelState: reduxState.effectsLevel,
  reactReduxThemeAndMusicSlotState: reduxState.themeAndMusicSlot
});

//This will map the dispatch function with specific action objects that you want to pass as props to the DrumMachineComponent component.
const mapDispatchToProps = (dispatch) => ({
  reactReduxSetVolumeLevelLower: () => dispatch(setVolumeLevelLowerActionCreator()),
  reactReduxSetVolumeLevelHigher: () => dispatch(setVolumeLevelHigherActionCreator()),
  reactReduxSpecifyVolumeLevel: (specificVolumeLevel) => dispatch(specifyVolumeLevelActionCreator(specificVolumeLevel)),
  reactReduxSpecifyEffectsLevel: (effectsLevelSetting) => dispatch(effectsLevelActionCreator(effectsLevelSetting)),
  reactReduxChangeThemeAndMusicSlot: (themeAndMusicSlot) => dispatch(selectedThemeAndMusicSlotActionCreator(themeAndMusicSlot))
});

//This is where your React DrumMachineComponent component will be connected to the Redux store with the MarkdownPreviewerContainer wrapper component.
const DrumMachineContainer = connect(mapStateToProps, mapDispatchToProps)(DrumMachineComponent);

//This AppWrapper class component will render your DrumMachineContainer component.
class AppWrapper extends React.Component {
  constructor(props) {
    super(props);
  }
 
  render() {
    return(
      //The two props of the Provider component are the Redux store object and the component inside of the DrumMachineContainer component.
      <Provider store={store}>
        <DrumMachineContainer/>
      </Provider>
    );
  }
};

//This ReactDOM.render() will render your React component to a div with an id of react-component-container in the HTML body element.
ReactDOM.render(<AppWrapper/>, document.getElementById("react-redux-component"));
              
            
!
999px

Console