var caminhoImagens = '/sistema_acordes/img/'; var linkAlteracao = '/sistema_acordes/include/acordes.php?acordes='; var listaDeAcordes = new Array(); var divId = "acorde"; var instrumentoMusical = ''; var instrumentoDefault = 'violao'; var dedosNotas = new Array(); var posCasas = new Array(); var totalAcordes = 0; var imagensAcorde = new Array(); var acordes = { arrayCaracteres : new Array( ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '', 'Ç', 'ü', 'é', 'â', 'ä', 'à', 'å', 'ç', 'ê', 'ë', 'è', 'ï', 'î', 'ì', 'Ä', 'Å', 'É', 'æ', 'Æ', 'ô', 'ö', 'ò', 'û', 'ù', 'ÿ', 'Ö', 'Ü', 'ø', '£', 'Ø', '×', 'ƒ', 'á', 'í', 'ó', 'ú', 'ñ', 'Ñ', 'ª', 'º', '¿', '®', '¬', '½', '¼', '¡', '«', '»', '_', '_', '_', '¦', '¦', 'Á', 'Â', 'À', '©', '¦', '¦', '+', '+', '¢', '¥', '+', '+', '-', '-', '+', '-', '+', 'ã', 'Ã', '+', '+', '-', '-', '¦', '-', '+', '¤', 'ð', 'Ð', 'Ê', 'Ë', 'È', 'i', 'Í', 'Î', 'Ï', '+', '+', '_', '_', '¦', 'Ì', '_', 'Ó', 'ß', 'Ô', 'Ò', 'õ', 'Õ', 'µ', 'þ', 'Þ', 'Ú', 'Û', 'Ù', 'ý', 'Ý', '¯', '´', '­', '±', '_', '¾', '¶', '§', '÷', '¸', '°', '¨', '·', '¹', '³', '²', '_', ' ') , doc : function ( id ) { return document.getElementById ( id ); } , visibilidadeTabela : function () { if ( totalAcordes.length > 0 ) { this.doc('tabela_tons').style.display = 'block'; this.doc('ico_aculta_acorde').style.display = 'block'; this.doc('ac').style.display = 'block'; /*this.doc('tabela_tons').innerHTML = '
Mudança de tom: -1 tom | -½ tom | +½ tom | +1 tom
Preferências: Selecionar
';*/ } if ( totalAcordes.length <= 0 ) { this.doc('tabela_acordes').style.display = 'none'; } } , buscarAcordes : function () { texto = this.doc('text'); totalAcordes = document.getElementsByTagName("tt"); this.visibilidadeTabela(); i = 0; while( i < totalAcordes.length ) { totalAcordes[i].onmouseover = this.mostrar; totalAcordes[i].onmouseout = this.esconder; totalAcordes[i].onmousemove = this.posiciona; pegandoAcorde = totalAcordes[i].firstChild.nodeValue; this.listandoAcordes ( pegandoAcorde ); i++; } } , listandoAcordes : function ( acorde ) { for (var i = 0; i < listaDeAcordes.length; i++) { if (listaDeAcordes[i] == acorde) { return; } } listaDeAcordes.push(acorde); } , instrumentoMusical : function ( instr ) { if ( !instr ) { instrumentoMusical = instrumentoDefault; } else { instrumentoMusical = instr; } } , buscarCoordenadas : function() { var acorde = ''; var novoAcorde = ''; var verificaC = ''; for (var i = 0; i < listaDeAcordes.length; i++) { verificaC= listaDeAcordes[i]; if ( (verificaC != null) && (verificaC.indexOf('null') < 0 ) ){ novoAcorde = ''; for (var j = 0; j <= verificaC.length; j++){ if (verificaC.charAt(j) == '#'){ novoAcorde += 'w'; }else{ if (verificaC.charAt(j) == 'º'){ novoAcorde += 'Y'; }else{ if (verificaC.charAt(j) == '°'){ novoAcorde += 'Y'; }else{ if (verificaC.charAt(j) == '+'){ novoAcorde += 'T'; }else{ if (verificaC.charAt(j) == '-'){ novoAcorde += 'R';} else novoAcorde += verificaC.charAt(j); } } } } } acorde += ( (acorde == '') ? '' : '_') + novoAcorde; } } localScript = this.doc('script_array'); novoTagScript = document.createElement('script'); instrumento_musical = '&inst=' + instrumentoMusical; novoTagScript.setAttribute('src' , linkAlteracao + acorde + instrumento_musical); localScript.appendChild( novoTagScript ); } , montarAcordes : function () { posAc = 0; localTabelaAcordes = this.doc('tabela_acordes'); localTabelaAcordes.innerHTML = 'Carregando'; tabelaAcordes = ''; pegandoAcorde = ''; linhas = 1; posJ = 0; existaArray = ''; if (instrumentoMusical == 'teclado' ) { posJ = 4; } else { if (instrumentoMusical == 'violao') { posJ = 9; } else { posJ = 10; } } for (posAc = 0; posAc < listaDeAcordes.length; posAc++) { pegandoAcorde = listaDeAcordes[posAc]; existaArray = acordes[pegandoAcorde]; if ( ( existaArray ) && (existaArray.length > 0 ) ) { if( linhas == posJ) { tabelaAcordes += ''; linhas = 1; } else { if (linhas ==1) { tabelaAcordes += ''; } } acordeSelecionado = acordes[pegandoAcorde][0]; if(instrumentoMusical=='violao'){ var aux_variar = 'variar'; } if(instrumentoMusical=='cavaco'){ var aux_variar = 'variar_cavaco'; } if(instrumentoMusical=='teclado'){ var aux_variar = 'variar_teclado'; } variarAcorde = ( acordes[pegandoAcorde].length > 1 ) ? 'Variar' : ''; if ( acordeSelecionado ) { tabelaAcordes += ''; } linhas++; } } tabelaAcordes += '
' + pegandoAcorde + '
'; switch ( instrumentoMusical ) { case 'violao' : { tabelaAcordes += this.instrumentoCordas ( 6 , acordeSelecionado , pegandoAcorde ); break; } case 'cavaco' : { tabelaAcordes += this.instrumentoCordas ( 4 , acordeSelecionado , pegandoAcorde ); break; } case 'teclado' : { tabelaAcordes += this.teclado ( acordeSelecionado , pegandoAcorde ); break; } } tabelaAcordes += '
'; tabelaAcordes += (acordes[pegandoAcorde].length > 0 ) ? '' + variarAcorde : ''; tabelaAcordes += '
'; localTabelaAcordes.innerHTML = tabelaAcordes; } , posicaoCasa : function (ac) { menor = 1000; maior = 0; posI = 0; separa = ac.split('_'); if ( separa.length > 0 ) { n = ''; var N = ''; var n1 = ''; for (posI = 0; posI < separa.length; posI++ ) { n = separa[ posI ].indexOf('X'); N = ''; n1 = ''; if ( n == -1 ) { n = separa[ posI ].indexOf('P'); if ( n == -1 ) { n1 = separa[ posI ].split('N'); N = n1[1]; dedosNotas.push('N'); } else { n1 = separa[ posI ].split('P'); dedosNotas.push('P'); N = n1[1]; } } else { posCasas.push(0); dedosNotas.push('X'); } if ( N ) { N = parseInt(N); posCasas.push(N); if ( N > maior ) { maior = N; } if ( ( N < menor ) && ( N != 0 ) ) { menor = N; } } } } return { menorValor : menor , maiorValor : maior } } , isArray : function (o) { return ( ( o.length)== 'undefined' ) ? false : true; } , teclado : function ( ac , nota ) { montaTabela = ''; tamanhoX = 4; for ( i = 1; i <= 33; i++) { separaPosicao = ac.split('_'); separaNota = ''; m = ''; for ( j = 0; j < separaPosicao.length; j++) { pegaPosicao = separaPosicao[j]; n = ''; pos = ''; separaNota = pegaPosicao.indexOf('P'); if ( separaNota == -1) { separaNota = separaPosicao[j].indexOf('B'); if ( separaNota > -1 ) { n = pegaPosicao.split ( 'B' ); pos = n[1]; if (pos == i ) { imagem = caminhoImagens + 'teclado/ponto_branco.gif" class="ponto_branco'; montaTabela += ''; imagensAcorde.push ( imagem ); m = i; } } } else { n = pegaPosicao.split ( 'P' ); pos = n[1]; if (pos == i ) { imagem = caminhoImagens + 'teclado/ponto_preto.gif" class="ponto_preto"'; montaTabela += ''; m = i; imagensAcorde.push ( imagem ); } } } if ( m == '' ) { montaTabela += ''; } } montaTabela += '
 
'; img_bg = caminhoImagens + 'teclado/bg_teclado.gif" class="img_teclado'; imagensAcorde.push ( img_bg ); img_bg = ''; return img_bg + montaTabela; } , instrumentoCordas : function ( nCordas , ac , nota ) { if (dedosNotas.length > 0) { while ( dedosNotas.length != 0) { dedosNotas.shift(); } } if (posCasas.length > 0) { while ( posCasas.length != 0) { posCasas.shift(); } } separarNotas = new Array(); posNota = ''; dedoCasa = 0; separarNotas = ac.split('_'); tabelaNotas = ''; tamanhoN = this.posicaoCasa(ac); menor = tamanhoN.menorValor; maior = tamanhoN.maiorValor; n1 = 1; n2 = 5; dedoCasa = ''; d = ''; p = false; intervalo = maior - menor; nDedo = 1; tamanhoY = '14'; setar = 0; concatenar = 0; dFinal = ''; polegar = false; qtdadeDireita = 0; if( ( ( menor >= 0 ) && ( intervalo >= 4 ) ) || (menor > 5 ) || ( ( menor >= 4 ) && ( intervalo > 1 ) ) || ( (menor >= 5 ) && (intervalo > 0 ) ) || ( (menor >= 3 ) && (intervalo >= 3 ) ) ) { if ( menor == 0 ) { if ( maior > 5) { n1 = maior; n2 = maior + 4; } } else { n1 = menor; n2 = menor + 4; } setar = n1; } for (var i = n1; i <= n2; i++) { tabelaNotas += ''; d = ''; for (var j = -1; j < nCordas; j++) { if ( j == -1 ) { tabelaNotas += ''; } else { d = ''; m = posCasas[j]; d = dedosNotas[j]; imagem = ''; if ( qtdadeDireita == j ) { switch ( d ) { case 'P': { if (polegar == false) { imagem = caminhoImagens + instrumentoMusical + '/cheia.gif'; dFinal += ''; polegar = true; } else { imagem = caminhoImagens + instrumentoMusical + '/null.gif'; dFinal += ''; } qtdadeDireita++; break; } case 'N': { if (polegar == false) { imagem = caminhoImagens + instrumentoMusical + '/cheia.gif'; dFinal += ''; polegar = true; } else { imagem = ''; dFinal += ''; imagensAcorde.push ( imagem ); } qtdadeDireita++; break; } case 'X': { imagem = ''; dFinal += ''; qtdadeDireita++; break; } } } if (d == 'P') { if ( ( i == m ) && ( p == false ) ) { dedoCasa = caminhoImagens + instrumentoMusical +'/pestana.gif'; concatenar = Math.abs( j - ( nCordas ) ); imagem = ''; tabelaNotas += ''; imagensAcorde.push ( imagem ); p = true; j = 8; nDedo++; } else { if ( ( p == true ) &&(i != m ) ) { tabelaNotas += ''; } } } else { dedoCasa = ''; tabelaNotas += ''; } } } tabelaNotas += ''; } dFinal = '' + dFinal + '' tabelaNotas += ( dFinal + '
'; if ( ( setar > 0 ) && ( setar == i ) ) { tabelaNotas += '' +setar + 'ª'; } else { tabelaNotas += ''; } tabelaNotas += '' + imagem + '' + imagem + '' + imagem + ''; if ( i == m ) { if( dedosNotas[j] == 'N') { dedoCasa = caminhoImagens + instrumentoMusical +'/' + nDedo + '.gif'; nDedo++; } tabelaNotas += ''; } else { tabelaNotas += ''; } tabelaNotas += '
' ); fundo = caminhoImagens + instrumentoMusical + '/bg_braco.gif" class="img_' + instrumentoMusical; imagensAcorde.push ( dedoCasa ); fundo = ''; return ( fundo + tabelaNotas ); } , limparArrays : function () { if (listaDeAcordes.length > 0) { for ( i = 0 ; i < listaDeAcordes.length; i++) { pos = ( listaDeAcordes[ i ] ) ? ( listaDeAcordes[ i ] ) : ''; if ( ( pos.length != '' ) && ( acordes[pos] ) ) { if ( acordes[pos].length > 0) { while ( acordes[pos].length != 0) { acordes[pos].shift(); } } } } } while ( listaDeAcordes.length != 0) { listaDeAcordes.shift(); } if ( imagensAcorde.length > 0 ) { while ( imagensAcorde.length != 0) { imagensAcorde.shift(); } } } , limparTabelas : function () { localTabelaAcordes = this.doc('tabela_acordes'); localTabelaAcordes.innerHTML = ''; } , carregarImagens : function () { imagens = new Image(); if ( imagensAcorde.length > 0 ) { for ( i = 0; i < imagensAcorde.length; i++ ) { imagens.src = imagensAcorde[i]; } } } , inicializar : function ( instr ) { this.limparTabelas(); this.limparArrays(); this.buscarAcordes(); this.instrumentoMusical( instr ); this.buscarCoordenadas(); } , inicializarRapido : function ( instr ) { this.limparTabelas(); this.limparArrays(); this.buscarAcordes(); this.instrumentoMusical( instr ); this.montarAcordes(); } , mostrar : function() { pegandoAcorde = this.innerHTML; verificandoTexto = ''; retornaLayoutAcorde = acordes.doc('acorde_' + pegandoAcorde); if ( retornaLayoutAcorde ) { tamanhoDivX = retornaLayoutAcorde.offsetWidth; tamanhoDivY = retornaLayoutAcorde.offsetHeight; verificandoTexto = retornaLayoutAcorde; if ( ( acordes[pegandoAcorde] != '' ) && ( retornaLayoutAcorde != '') ) { if (verificandoTexto != 'null') { acordes.doc( divId ).style.visibility = 'visible'; acordes.doc( divId ).style.width = tamanhoDivX + 10 + 'px'; acordes.doc( divId ).style.height = tamanhoDivY + 10 + 'px'; acordes.doc( divId ).innerHTML = retornaLayoutAcorde.innerHTML; } } } } , esconder : function() { acordes.doc(divId).innerHTML = '';; acordes.doc(divId).style.visibility = 'hidden'; } , posiciona : function () { alteraPosicao = acordes.doc( divId ); posicaoX = "" + ( X + 30 ) + "px"; posicaoY = "" + ( Y - 360 ) + "px"; alteraPosicao.style.top = posicaoY; alteraPosicao.style.left = posicaoX; } , trocarInstrumento : function() { num = this.doc('muda_acordes'); pos = num.selectedIndex; instr = num[pos].value; if ( instr ) { this.inicializar( instr ); } } , variar : function ( acorde ) { variacao = parseInt( document.getElementById('var_' + acorde).value ); soma = variacao + 1; tamanhoVariacao = acordes[acorde].length; variacao = ( soma < tamanhoVariacao) ? soma : 0; variandoAcorde = this.doc('acorde_' +acorde); var atualizandoAcorde = ''; if ( variandoAcorde ) { atualizandoAcorde += '
' + acorde + '
'; switch ( instrumentoMusical ) { case 'violao' : { atualizandoAcorde += this.instrumentoCordas ( 6 , acordes[acorde][variacao] , acorde ); break; } case 'cavaco' : { atualizandoAcorde += this.instrumentoCordas ( 4 , acordes[acorde][variacao] , acorde ); break; } case 'teclado' : { atualizandoAcorde += this.teclado ( acordes[acorde][variacao] , acorde ); break; } } this.doc('var_' + acorde).value = variacao; variandoAcorde.innerHTML = atualizandoAcorde; } } , alteraTom : function(funcao , tipoTom) { texto = this.doc('text'); totalAcordes = document.getElementsByTagName("tt"); var posI = 0; pegaNotaTom = ''; novaNota = ''; while ( posI < totalAcordes.length ) { pegaNotaTom = totalAcordes[posI].innerHTML; novaNota = pegaNotaTom; for (var j = 1; j <= tipoTom; j++) { switch ( funcao ) { case 'aumentarMeioTom' : { novaNota = this.aumentarMeioTom( novaNota ); break; } default : { novaNota = this.diminuiMeioTom( novaNota ); break; } } } totalAcordes[posI].firstChild.nodeValue = novaNota; posI++; } this.inicializar( instrumentoMusical ); } , aumentarMeioTom : function( ac ) { retorno = ''; for (tamanhoAc = 0; tamanhoAc < ac.length; tamanhoAc++) { if ( ( this.caracteresParaByte( ac.charAt(tamanhoAc) ) >= 65) && ( this.caracteresParaByte( ac.charAt(tamanhoAc) ) <= 71) ) { if ( ac.charAt(tamanhoAc+1) == "b" ) { retorno += ac.charAt(tamanhoAc); } else { if (ac.charAt(tamanhoAc+1) == "#") { if ( ( this.caracteresParaByte(ac.charAt(tamanhoAc)) >= 65) && (this.caracteresParaByte(ac.charAt(tamanhoAc)) <= 70) ) { retorno += String.fromCharCode(( this.caracteresParaByte(ac.charAt(tamanhoAc)) + 1)); } else { retorno += "A"; } } else { if ( (ac.charAt(tamanhoAc) == "A") || (ac.charAt(tamanhoAc) == "C") || (ac.charAt(tamanhoAc) == "D") || (ac.charAt(tamanhoAc) == "F") || (ac.charAt(tamanhoAc) == "G") ) { retorno += ac.charAt(tamanhoAc) + "#"; } else { retorno += String.fromCharCode(this.caracteresParaByte(ac.charAt(tamanhoAc)) +1 ); } } } } else { if ( (ac.charAt(tamanhoAc) != "b") && (ac.charAt(tamanhoAc) != "#") ) { retorno += ac.charAt(tamanhoAc); } } } return retorno; } , diminuiMeioTom : function ( ac ) { retorno = ''; for (var tamanhoAc = 0; tamanhoAc < ac.length; tamanhoAc++) { if ( ( this.caracteresParaByte( ac.charAt(tamanhoAc) ) >= 65) && ( this.caracteresParaByte(ac.charAt(tamanhoAc)) <= 71) ) { if (ac.charAt(tamanhoAc + 1) == "b") { if ( (this.caracteresParaByte( ac.charAt(tamanhoAc) ) >= 66) && (this.caracteresParaByte( ac.charAt(tamanhoAc) ) <= 71) ) { retorno = retorno + String.fromCharCode(this.caracteresParaByte( ac.charAt(tamanhoAc) ) - 1); } else { retorno = retorno + "G" ; } } else { if (ac.charAt(tamanhoAc+1) == "#") { retorno = retorno + ac.charAt(tamanhoAc); } else { if ( (ac.charAt(tamanhoAc) == "A") || (ac.charAt(tamanhoAc) == "B") || (ac.charAt(tamanhoAc) == "D") || (ac.charAt(tamanhoAc) == "E") || (ac.charAt(tamanhoAc) == "G") ) { if (ac.charAt(tamanhoAc) != "A") { retorno +=String.fromCharCode(this.caracteresParaByte( ac.charAt(tamanhoAc) ) - 1) + "#"; } else { retorno += "G#"; } } else { retorno = retorno + String.fromCharCode(this.caracteresParaByte(ac.charAt(tamanhoAc)) - 1); } } } } else { if ( (ac.charAt(tamanhoAc) != "b") && (ac.charAt(tamanhoAc) != "#") ) { retorno = retorno + ac.charAt(tamanhoAc); } } } return retorno; } , caracteresParaByte : function ( c ) { var numByte = 0; while (numByte < this.arrayCaracteres.length) { if (c == this.arrayCaracteres[ numByte ]) { return numByte + 32; } numByte++; } return 0; } , destacarSelect : function () { lista = this.doc('muda_acordes'); opcao = ( instrumentoMusical != '') ? instrumentoMusical : instrumentoDefault; for (i = 0; i < lista.length; i++) { if (lista[i].value == opcao) { lista.selectedIndex = i; } } } }