Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Javascript & jQuery Powered Music Player #14

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added favicon.ico
Binary file not shown.
43 changes: 33 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,68 @@
<script type="text/javascript" src="noise.js"></script>
</head>
<body>

<center><h1 id="title"> Xylophonic
</h1>
</center>

<center><h1 class="intro">Instructions</h1>
<p class="intro2">
Make music with clicks or with keys.

Notes correspond to the following keys on a standard laptop keyboard.
</p>
<h1 class="keys">[x][c][v][b][n][m][,]</h1>



</center>


<div id="audio_embeds">

<audio id="cAudio">
<source src="media/c_note.mp3" type="audio/mpeg"></source>

<source src="media/c_note.ogg" type="audio/ogg"></source>
<source src="media/c_note.wav" type="audio/wav"></source>

<source src="media/c_note.wav" type="audio/wav"></source>
</audio>

<audio id="dAudio">
<source src="media/d_note.mp3" type="audio/mpeg"></source>
<source src="media/d_note.ogg" type="audio/ogg"></source>
<source src="/media/d_note.wav" type="audio/wav"></source>
</audio>
<source src="/media/d_note.wav" type="audio/wav"></source>
</audio>
<audio id="eAudio">
<source src="media/e_note.mp3" type="audio/mpeg"></source>
<source src="media/e_note.ogg" type="audio/ogg"></source>
<source src="media/e_note.wav" type="audio/wav"></source>
<source src="media/e_note.wav" type="audio/wav"></source>
</audio>
<audio id="fAudio">
<source src="media/f_note.mp3" type="audio/mpeg"></source>
<source src="media/f_note.ogg" type="audio/ogg"></source>
<source src="media/f_note.wav" type="audio/wav"></source>
<source src="media/f_note.wav" type="audio/wav"></source>
</audio>
<audio id="gAudio">
<source src="media/g_note.mp3" type="audio/mpeg"></source>
<source src="media/g_note.ogg" type="audio/ogg"></source>
<source src="media/g_note.wav" type="audio/wav"></source>
<source src="media/g_note.wav" type="audio/wav"></source>
</audio>
<audio id="aAudio">
<source src="media/a_note.mp3" type="audio/mpeg"></source>
<source src="media/a_note.ogg" type="audio/ogg"></source>
<source src="media/a_note.wav" type="audio/wav"></source>
<source src="media/a_note.wav" type="audio/wav"></source>
</audio>
<audio id="bAudio">
<source src="media/b_note.mp3" type="audio/mpeg"></source>
<source src="media/b_note.ogg" type="audio/ogg"></source>
<source src="media/b_note.wav" type="audio/wav"></source>
<source src="media/b_note.wav" type="audio/wav"></source>
</audio>
</div>
<div class="instrument">
<button class="note c">c</button>

<div class="instrument">
<button class="note c">c</button>
<button class="note d">d</button>
<button class="note e">e</button>
<button class="note f">f</button>
Expand Down
31 changes: 30 additions & 1 deletion noise.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@import url('https://fonts.googleapis.com/css?family=Monofett');

html {
font-size: 16px;
}

body {
background-color: black;
background-color: black;
}

.instrument {
Expand Down Expand Up @@ -51,3 +53,30 @@ body {
.b { color: #f26fd4; background-color: #43293d; }
.b:hover { background-color: #6f3a62; }
.b:active, .b.active { background-color: #f26fd4; }


#title {
color: red;
font-weight: bold;
font-family: 'Monofett', cursive;
font-weight: bolder;
font-size: 90px;

}

.intro {
color: white;
font-family: monospace;
}

.intro2 {
color: white;
font-family: monospace;
font-size: 20px;
}

.keys {
color: white;
font-family:monospace;
font-size: 30px;
}
115 changes: 115 additions & 0 deletions noise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,118 @@
$(document).ready( function() {
// your code here
// potential keys to use.
// x = 120 (note c) // c = 99 (note d)// v = 118 (note e)// b = 98 // n = 78// m = 77 //
// target box button class C & aim
$(".c").click(function(){

// alert("this worked!"); // this checks to see if it will alert once clicked.

// now select your audio you wish to be played.

$('#cAudio').trigger('play');
});

// attach c-note to key x
$('body').keypress(function(event){
console.log("hello you!" + event.keyCode);
// this is special code that loads it before. thus making it be able to be hit & play each time.
$('#cAudio').load();
if(event.keyCode == 120){
$('#cAudio').trigger('play');
}
});


// ------------------------------//

//select d button play D note
$(".d").click(function() {
// play dAudio
$("#dAudio").trigger('play');
});
// attach d note to key c
$('body').keypress(function(event){
// special
$('#dAudio').load();
if(event.keyCode == 99 ){
$('#dAudio').trigger('play');
}
});

// ------------------------------//

// play E note
$(".e").click(function(){
$("#eAudio").trigger('play');
});
// attach e note to key v
$('body').keypress(function(event){
//special
$('#eAudio').load();
if(event.keyCode == 118 ){
$('#eAudio').trigger('play');
}
});

// ------------------------------//

// play f note
$(".f").click(function(){
$("#fAudio").trigger('play');
});
// attach f note to key b
$('body').keypress(function(event){
//special
$('#fAudio').load();
if(event.keyCode == 98 ){
$('#fAudio').trigger('play');
}
});

// ------------------------------//
$(".g").click(function(){
$("#gAudio").trigger('play');
});

// attach g note to key n
$('body').keypress(function(event){
// special
$('#gAudio').load();
if(event.keyCode == 110 ){
$('#gAudio').trigger('play');
}
});

// ------------------------------//
// play a note
$(".a").click(function(){
$("#aAudio").trigger('play');
});

// attach g note to key m // 109
$('body').keypress(function(event){
$('#aAudio').load();
if(event.keyCode == 109 ){
$('#aAudio').trigger('play');
}
});

// ------------------------------//
// 44
// play b note.
$(".b").click(function(){
$("#bAudio").trigger('play');
});
$('body').keypress(function(event){
$('#bAudio').load();
if(event.keyCode == 44 ){
$('#bAudio').trigger('play');
}
});






}); // end of code block
24 changes: 24 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Notes

1. http://codesamplez.com/programming/control-html5-audio-with-jquery
- This article goes into great detail about loading & playing audio files.


$('body').keypress(function(event){
if(event.keyCode == 88){
$('#cAudio').trigger('play');

2. console.log("hello you!" + event.keyCode);


check out what code was actually pressed.


3.
$('body').on('keypress',function(event){
if(event.keyCode == 120){
console.log("this is key", event.keypress);
$('#cAudio').trigger('play');
}
});
});