cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <header>
		<h1 id="title">Online Guitar Tuner</h1>
		<a class="josetxu" href="http://josetxu.com/" target="_blank">josetxu.com</a>
	</header>
    <section id="guitarBody">
		<button onmouseover="pickString(this.id)" onclick="clickString(this.id)" class="string" id="s6"></button>
		<button onmouseover="pickString(this.id)" onclick="clickString(this.id)" class="string" id="s5"></button>
		<button onmouseover="pickString(this.id)" onclick="clickString(this.id)" class="string" id="s4"></button>
		<button onmouseover="pickString(this.id)" onclick="clickString(this.id)" class="string" id="s3"></button>
		<button onmouseover="pickString(this.id)" onclick="clickString(this.id)" class="string" id="s2"></button>
		<button onmouseover="pickString(this.id)" onclick="clickString(this.id)" class="string" id="s1"></button>
		<div class="notes">
			<span class="lightOff" id="s6Note">E<span class="notas">MI</span></span>
			<span class="lightOff" id="s5Note">A<span class="notas">LA</span></span>
			<span class="lightOff" id="s4Note">D<span class="notas">RE</span></span>
			<span class="lightOff" id="s3Note">G<span class="notas">SOL</span></span>
			<span class="lightOff" id="s2Note">B<span class="notas">SI</span></span>
			<span class="lightOff" id="s1Note">E<span class="notas">MI</span></span>
		</div>
	</section>
	<footer>
		<button onclick="stopStrings()" class="inactive" id="btnStop">STOP</button>
		<button onclick="usePick()" class="inactive" id="btnPick">PICK</button>
		<button onclick="holdSound()" class="inactive" id="btnHold">HOLD</button>
	</footer>
            
          
!
            
              body {
	background: url(https://goo.gl/OiZuWr)repeat center center #000;
	font-family: Arial, Helvetica, San-serif;
	margin:0;
	outline: none;
}
header {
    height: 15vh;
    color: #151515;
    text-align: center;
    margin: 0;
    padding: 0.5vh;
    box-shadow: 0 0 25px 5px #000;
	box-sizing: border-box;
    border-bottom: 1px solid #111;
	background:url(https://goo.gl/v3Kc1o) repeat-x center center / contain transparent;
	position: relative;
}
h1 {
    margin: 0.5vh 0;
    font-size: 2em;
    padding: 3vh 0;
    background-color: #333333;
    -webkit-background-clip: text;
    -moz-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: rgba(255,255,255,0.5) 0px 1px 3px;  
}
h1#title.imgTitle{
	text-shadow: 0 0 25px rgba(20, 139, 255, 0.8), 0 0 15px rgba(30, 144, 255, 0.54);
    background-color: rgba(77, 134, 189, 0.8);
}
a.josetxu {
    position: absolute;
    right: 0px;
    top: 10px;
    text-decoration: none;
    font-size: 10px;
    color: #333;
    width: 33%;
    opacity: 0.5;
    margin: 0 33%;
}
a.josetxu:hover {
	opacity:1;
}
section {
	margin: 0 auto;
    float: none;
    height: 70vh;
    background: url(https://goo.gl/wXHQQG) no-repeat center 50% transparent;
    width: 360px;
    box-sizing: border-box;
}
button.string {
	border: none;
    float: left;
    width: 40px;
    margin: 0 7px 0 7px;
    height: inherit;
    outline: none;
    cursor: pointer;
    padding: 0 !important; 
	z-index: 1;
}

button.string:first-child {
    margin-left: 26px !important;
}

button#s6, button#s4, button#s4, button#s3, button#s1 {
    margin-left: 6px;
}
button#s2 {
    margin-left: 8px;
}

#guitarBody button {
	background-repeat:repeat-y ;
	background-position:center center;
	background-color:transparent;
}

#s1 {
	background-image: url(https://goo.gl/87LmLL); /*1.png*/
}
#s2 {
	background-image: url(https://goo.gl/2HdLQL);
}
#s3 {
	background-image: url(https://goo.gl/Zp7EnI);
}
#s4 {
	background-image: url(https://goo.gl/gqYw0K);
}
#s5 {
	background-image: url(https://goo.gl/wZCi52);
}
#s6 {
	background-image: url(https://goo.gl/5Whvqm);
}

#s1:hover {
	background-image: url(https://goo.gl/X5XRO6), url(https://goo.gl/87LmLL); /*brillo1|1.png*/
}
#s2:hover {
	background-image: url(https://goo.gl/X5XRO6), url(https://goo.gl/2HdLQL);
}
#s3:hover {
	background-image: url(https://goo.gl/X5XRO6), url(https://goo.gl/Zp7EnI);
}
#s4:hover {
	background-image: url(https://goo.gl/wV2vFA), url(https://goo.gl/gqYw0K);
}
#s5:hover {
	background-image: url(https://goo.gl/wV2vFA), url(https://goo.gl/wZCi52);
}
#s6:hover {
	background-image: url(https://goo.gl/q50FT0), url(https://goo.gl/5Whvqm);
}

#guitarBody button.string.playingSound {
	background-repeat:repeat-y, repeat-y, no-repeat !important;
	background-position:center center, center center, center 50% !important;
	background-color:transparent;
}
#s1.string.playingSound {	
	background-image: url(https://goo.gl/LQF8DD), url(https://goo.gl/X5XRO6), url(https://goo.gl/cx2PAC); /*1.gif|luz.png*/
}
#s2.string.playingSound {	
	background-image: url(https://goo.gl/CXfeSQ), url(https://goo.gl/X5XRO6), url(https://goo.gl/cx2PAC);
}
#s3.string.playingSound {	
	background-image: url(https://goo.gl/CXfeSQ), url(https://goo.gl/X5XRO6), url(https://goo.gl/cx2PAC);
}
#s4.string.playingSound {	
	background-image: url(https://goo.gl/rUVtU6), url(https://goo.gl/wV2vFA), url(https://goo.gl/cx2PAC);
}
#s5.string.playingSound {	
	background-image: url(https://goo.gl/daJySi), url(https://goo.gl/wV2vFA), url(https://goo.gl/cx2PAC);
}
#s6.string.playingSound {	
	background-image: url(https://goo.gl/3SwDif), url(https://goo.gl/q50FT0), url(https://goo.gl/cx2PAC);
}



/******** CONTROLS *******/
footer {
    margin: 0;
    background-color: hsl(0,0%,90%);
    height: 15vh;
	text-align:center;
	bottom: 0;
    position: relative;
    width: 100%;
	background:url(https://goo.gl/v3Kc1o) repeat-x center center /contain transparent;
	box-shadow: 0 0 25px 5px #000;
}
footer button {
    font-size: 0;
    height: 9vh;
    width: 140px;
    margin: 3vh 1vh 0;
    border: none;
    outline: none;
    font-weight: bold;
    color: transparent;
    cursor: pointer;
	text-align: center;
}
/******* buttons ******/
#btnStop {
    background: url(https://goo.gl/lNfQmE) no-repeat center right /contain;
	text-align: left;
}
#btnHold {
    background: url(https://goo.gl/lNfQmE) no-repeat center left /contain;
	text-align: right;
}
#btnHold:after , #btnStop:before {
    content: "HOLD";
    font-size: 18px;
    background-color: #333333;
    -webkit-background-clip: text;
    -moz-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: rgba(255,255,255,0.5) 0px 1px 3px;
}
#btnStop:before {
    content: "STOP";
}
#btnHold.active:after, #btnHold:active:after {
	text-shadow: 0px 1px 3px rgba(255,255,255,0.3), 0 0 15px #59a0f4, 0 0 20px #59a0f4, 0 0 25px #59a0f4, 0 0 30px #59a0f4, 0 0 35px #59a0f4;
	color: #1e90ff;
}
#btnStop:active:before {
	text-shadow: rgba(255,255,255,0.5) 0px 1px 3px, 0 0 15px #ff0000, 0 0 20px #ff0000, 0 0 25px #ff0000;
	color: #ff0000;
}
#btnStop:active {
    background: url(https://goo.gl/kX2vGS) no-repeat center right /contain;
}
#btnHold.active, #btnHold:active {
    background: url(https://goo.gl/hdPdRZ) no-repeat center left /contain;
}
/****** pick *****/
#btnPick {
    background: url(https://goo.gl/hmiOXy) no-repeat center center /contain;
	width: 100px;
	font-size: 22px;
}
#btnPick.active{    
    background: url(https://goo.gl/CuQnnp) no-repeat center center /contain;
}
section.pickActive , section.pickActive .string{
	cursor: url(https://goo.gl/aefGMD)10 60, auto;
}

/* NOTES */
.notes {
    position: absolute;
    width: 330px;
    top: 22%;
    z-index: -1;
	margin-left: 20px;
}
.notes span {
    width: 50px;
    display: inline-block;
    color: #171717;
    text-align: center;
    font-size: 50px;
    z-index: 0;
    text-shadow: -1px -1px 1px #000000, 0px 0px 1px #6f6f6f;
}
.notes .lightOn, .notes .lightOn span {
	color: #71abeb;
    text-shadow: 0px 0px 15px #3779c5, 0px 0px 25px #3779c5, 0px 0px 35px #71abeb, -1px -1px 1px #000000, 0px 0px 1px #6f6f6f;
	transition: all 0.2s ease;
}
.notas {
    font-size: 22px !important;
	margin-top: 42vh;
}

/* MEDIA QUERIES */
@media only screen and (max-width: 380px){
	section {
		margin-left: 0;
	}
}

@media only screen and (max-width: 359px){
	section {
		margin-left: 0px;
		background-position-x: -26px;
	}
	
}

@media only screen and (max-width: 320px){
	section {
		width: 320px;
		padding-left: 5px;
		box-sizing: border-box;
		margin-right: 0;
		background-position-x: -21px;
	}
	.notes {
		width: 320px;
		margin-left: 0px;
	}
	.notes span {
		width: 48px;
	}
	button.string:first-child {
		margin-left: 0 !important;
	}
	button.string:last-child {
		margin-right: 0!important;
	}
}

/* Hide Pick if we have an inaccurate pointing device */
@media (pointer:coarse) {
	#btnPick {
		display:none !important;
	}
}

/* Hide Pick if orientation is portrait (vertical)*/
@media only screen and  (orientation : portrait) {
    #btnPick {
		display:none !important;
	}
}

            
          
!
            
              /* VARIABLES */
/* sounds */
var s1 = new Audio('http://josetxu.com/html5/guitar-tuner/audio/s1.mp3');
var s2 = new Audio('http://josetxu.com/html5/guitar-tuner/audio/s2.mp3');
var s3 = new Audio('http://josetxu.com/html5/guitar-tuner/audio/s3.mp3');
var s4 = new Audio('http://josetxu.com/html5/guitar-tuner/audio/s4.mp3');
var s5 = new Audio('http://josetxu.com/html5/guitar-tuner/audio/s5.mp3');
var s6 = new Audio('http://josetxu.com/html5/guitar-tuner/audio/s6.mp3');

/* FUNCTIONS */
/* short getElementById */
function elem(id){
	var element = document.getElementById(id);
	return element;
}
/* tuner functions */
function pickString(thisString){
	if(pick == true) clickString(thisString);
}
function clickString(thisString) {
	elem('title').className='imgTitle';
	elem(thisString).className = "string";
	window[thisString].currentTime = 0;
	window[thisString].play();
	var thisNote = thisString+"Note";
	elem(thisString).className = "string playingSound";
	elem(thisNote).className = "lightOn";
	setTimeout(function(){ 		
		if(window[thisString].loop != true){
			elem(thisString).className = "string";
			elem(thisNote).className = "lightOff";
			if(document.querySelectorAll('.playingSound').length==0){
				elem('title').className='';
			}
		}
	}, 4500);
}
function holdSound(){
	if(s1.loop != true){
		s1.loop = s2.loop = s3.loop = s4.loop = s5.loop = s6.loop = true;
		elem('btnHold').className = "active";
	} else {
		s1.loop = s2.loop = s3.loop = s4.loop = s5.loop = s6.loop = false;
		elem('btnHold').className = "inactive";
		s1.pause(); s2.pause(); s3.pause(); s4.pause(); s5.pause(); s6.pause();	
		stopStrings();
	}
}
function stopStrings(){
	elem('title').className='';
	s1.pause(); s2.pause(); s3.pause(); s4.pause(); s5.pause(); s6.pause();
	var auxString = document.querySelectorAll('.playingSound');	
	for (var x in auxString) {
		if(auxString[x]!==undefined){
			auxString[x].className = "string";
		}
	}
	var auxNote = document.querySelectorAll(".lightOn");
	for (x in auxNote) {
		if(auxNote[x]!==undefined){
			auxNote[x].className = "lightOff";
		}
	}
}
function usePick(){
	var x = elem('btnPick').className;
	if(x == 'inactive'){
		elem('btnPick').className = 'active';
		pick = true;
		elem("guitarBody").className = 'pickActive';	
	} else {
		elem('btnPick').className = 'inactive';
		pick = false;
		elem("guitarBody").className = '';	
	}
}
/* ON LOAD */
(function() {
	setTimeout(function(){ 		
		clickString('s3');
	}, 500);
})();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console