Garrapatea Library Documentation

Generic placeholder thumbnail

Label

Something else
Generic placeholder thumbnail

Label

Something else
Generic placeholder thumbnail

Label

Something else
Generic placeholder thumbnail

Label

Something else

File System

The file system is tow directories, one for the audio online sound and other for the javascript files.

Garrapatea DIRECTORY

Garrapatea library it's build uppon some JavaScript files. Look at the table.

Name Works On & Methods
almacena Store note objects in arrray almacen overrite array almacena(); overrriteAlmacen();
armadura Control the key signature feature store it in the array almacen nuevaArmadura(); testArmadura(); almacenaTonalidad(); dibujaArmadura();
browsers Browser compatibility bypass for audio API and other features browserCatch(); tryAPIsound(); tryHTMLsound(); tryJasmid()
controlbotones Pressed button controller get pixel control from "partitura" canvas clickeoEnCanvas(); ObtenPixelColor (); repartoAcciones();
coordenadasratoncanvas mouse coordinates over canvas coordenadasRatonCanvas();
imprimir print easy function imprimirPartitura();
interfacemidi midi file creator aMidi(); midiNota(); midiSilencio(); midiArray(); polifonia(); aFile()
loadaudio load feedback audio files for audioAPI loadAudio(); loadNote(); ejecutaNota();
loadaudioie load feedback audio for HTML5 auido bypassAudio(); loadHTMLnote(); ejecutaNotaHTML();
nuevabarra compass bar controller draw bars on compass nuevaBarra();
nuevaclave cleff paint controller nuevaClave();
nuevanota paint notes controller create object notes "Obnota" nuevaNota(); createObnota(); dibujaGrupoNotas(); alturaNota(); dibujaNota(); dibujaNotaAlterada();
nuevocompas paint the staves sheet innsert canvas for painting nuevoCompas(); nuevoCanvas();
nuevoritmo draw the rythm 2/4, 3/4, 4/4 nuevoRitmo();
nuevosilencio silence draw controller nuevoSilencio(); aJasmid(); aBgSound();
playonflight jasmid interface player aReproducir(); dibujaSilencio();
preview png image creator oppen in new tab muestraImagenPartitura();
redibujacanvas delete objects controller redraw canvas control redibujaCanvas(); borraCanvasAndRedibuja(); borraCanvasDom();
sonido play feedback notes translate to midi note number playNote(); getMidiNoteNumber();

Sonidosmin DIRECTORY

Used piano mp3 for a online sound feedback. You can change the files in this directory for your own files, like some guitar but remember to use the same name and format.

Name Format Key Midi number
48 mp3 C/4 48
49 mp3 C#/4 49
50 mp3 D/4 50
51 mp3 D#/4 51
52 mp3 E/4 52
53 mp3 F/4 53
54 mp3 F#/4 54
55 mp3 G/4 55
56 mp3 G#/4 56
57 mp3 A/4 57
58 mp3 A#/4 58
59 mp3 B/4 59
60 mp3 C/5 60
61 mp3 C#/5 61
62 mp3 D/5 62
63 mp3 D#/5 63
64 mp3 E/5 64
65 mp3 E/5 65
66 mp3 F/5 66
67 mp3 F#/5 67
68 mp3 G/5 68
69 mp3 G#/5 69
70 mp3 A/5 70
71 mp3 A#/5 71
72 mp3 B/5 72
73 mp3 C/6 73
74 mp3 C#/6 74
75 mp3 D/6 75
76 mp3 D#/6 76
77 mp3 E/6 77
78 mp3 F/6 78
79 mp3 F#/6 79
80 mp3 G/6 80
81 mp3 G#/6 81
82 mp3 A/6 82
83 mp3 A#/6 83
84 mp3 B/6 84
85 mp3 C/7 85
86 mp3 C#/7 86
87 mp3 D/7 87
88 mp3 D#/7 88
89 mp3 E/7 89
90 mp3 E#/7 90

Functions Review

Garrapateahas its divided in three parts.

  • The canvas "partitura"- formed by a growing number of 38 pixels canvas.
  • The array "almacen"- stores the objects and the position on the canvas "partitura".
  • The buttons or controllers- for creating objects.

We have several methods that intercat between this parts.

almacena (objet, canvasStaveId)

This method is used for save an object and the position into the canvas. Recieve a musical object like a note, cleff, rythm or bar and the respective position into the canvas "partitura".

overriteAlmacen (objet, canvasStaveId)

Substite an object with another object.

nuevaArmadura (counter, canvasStaveId)

Creates a newer key signature. Recieve a counter, for control the number of clicks on the canvas and the canvasId for a correct saving on "almacen".

testArmadura (note, keySignature)

Checks if one note is sharped or flatted for the effect of some key signature.

almacenaTonalidad (key, canvasStaveId)

Save the key signature in the array.

dibujaArmadura (key, canvasStaveId, a)

Control the key signature drawing on the canvas. The "a" object is a variable passed to this function for a better control the drawing. If exist paint on two canvas.

browserCatch ()

Function for control the browsers differences.

trySound ()

Test if the browser support the different APIs supported by Garrapatea Sound

tryAPIsound ()

Function created for trySound(). Test only if the APIsound is supported in the user's browser.

tryHTMLsound ()

Function created for trySound(). Test only if the HTML audio tag si supported by the user's browser. It's called only if the previous function(tryAPIsound) is false.

tryJasmid ()

Return true or false if the browser supports or not the jasmid library.

clickeoEnCanvas (event, canvasStaveId)

Function that works as a dynamic onclick listener. Get the context of the canvas.

obtenPixelColor (canvas_x, canvas_y, contexToPixel, canvasStaveId)

Tell us if the user click on the object. Objects in canvas are allways black in Garrapatea. If- it's black, call redibujaCanvas(), to redraw the canvas. Else- call repartoAcciones().

repartoAcciones (canvas_x, canvas_y, canvasStaveId)

Check the controlls and decide what acction is going to do.

coordenadasRatonCanvas (event, canvasStavedId)

Return the coordinates over the clicked canvas. X, Y and canvasStaveId.

imprimirPartitura ()

Print with the javascript print() function.

aMidi (arrayAlmacen)

Run over the array "almacen" and translate objects calling to the apropiate midiMessage function.

midiNota (objet)

translate teh objct Obnota, a note stored in the array, to the correct midiMessage and add it to the Miditrack. Use a series of calls to the MidiSketch library.

midiSilencio (objet)

The same as midiNota() but with silence objects.

midiArray (objetArray)

Called by aMidi() if the there are more than one object in the same canvas.

polifonia (notesMidi)

Used for create simple chords when midiArray call it.

aFile ()

Creates a blob and put inside the binary midi file, then call the native downloadad function for each browser.

loadAudio (directory)

Loads audio from sonidosmin DIRECETORY if you doesn't pass a path to a new directory. Load the audio only for webAudioAPI.

loadNote (pitch, url)

Called by previous function, loads every mp3 file to the buffer. Uses https request.

ejecutaNota (number)

Play the note from the buffer when recieve a Number (name) of the file

bypassAudio (directory)

Called when the Web Audio API is not supported and loads audio files from directory.

loadHTMLnote (pitch, url)

Do the same as loadNote but with HTML audio API.

ejecutaNotaHTML(number)

Do the same as ejecutaNota but with HTML audio API.

nuevaBarra (canvas_x, canvasStaveId)

Creates, stores and paints the bars for the staves.

nuevaClave (kind, canvasStaveID)

Creates, stores and paints the cleff on the canvas.

nuevaNota (canvas_y, canvasStaveId)

controls the new note creation. Check what note controlers the user has clicked and call the apropiate function.

createObNota ()

called by nuevaNota(), this function return a new note object.

dibujaGrupoNotas (startnotegroup, endnotegroup, notesarray, notesdurationarray, notesaccidentalarray, arraydots)

Function for correct drawing beam notes. Recieve groups of arrays for localize and paint over the canvas.

alturaNota (canvas_y)

Recieve the Y clicked coordinate over the canvas, and return the name of the note to nuevaNota().

dibujaNota (note, duration)

Draw a simply note, with no neighbours.

dibujaNotaAlterada (note, duration, accidental)

Draw the simply note and the accident selected by the user.

nuevoCanvas ()

Introduce a new canvas on the DOM of the HTML.

nuevoCompas (canvasId)

Draw the 5 lines of the stave on the canvas.

nuevoRitmo (rythmnumber, canvasStaveId)

Draw a new Rythm 2/4, 3/4, etc., on the stave.

nuevoSilencio (canvasStaveId)

Control the creation of a new Silence.

dibujaSilencio (duration)

Draw the correct silence. This function is called by the nuevoSilencio function.

aReproducir (SketchObject)

This function recieve a MidiSketch object. This object, created by the MidiSketch library and interactuate with this fuction as a bypass. It calls the native midi support for each browser.

aJasmid ()

The online call to play jasmid for opera, chrome and firefox.

aBgSound ()

Internet Explorer midi support.

muestraImagenPartitura ()

Controlls the creation of a PNG image frome the canvas objects.

redibujaCanvas (canvasStaveId, pixelcontext)

Redraw the canvas if the pixel is black. It works with colaboration of nuevoCompas().

borraCanvasAndRedibuja (canvasStaveId)

Make the same as redibujaCanvas() but without call other function.

borraCanvasDom ()

Delte the last canvas from the DOM tree.

playNOte (ObNote, soundCkecked)

Call to get the midi note number, check the sound browser support and call the correct function for playing the feedback mp3 sounds.

getMidiNoteNumber (Obnota)

Recieve the Obnote object and return the correct midi note number.

CSS Selectors

Garrapatea uses a serie of css selectors to help to change the style.

class="botones"

For normal buttons. +, -, PNG, toMidiButton, play, etc,.

class="radio"

For radio buttons. The rest of user control buttons. Use the class and one number to make button groups.

id="partitura"

Its the place where is located the canvas where garrapatea draws the stave. Its a div.

id="fondo"

This CSS selector its a container div for all garrapatea APP.

id="audio"

A hidden div where we store the HTML audio tags when the Web Audio API it's not supported

Licenses

Jasmid License

Copyright (c) 2010, Matt Westcott & Ben Firshman

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Vex-Flow License

Vex Flow - A JavaScript library for rendering music notation. Copyright (c) 2010 Mohit Muthanna Cheppudira

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MidiSketch License

Copiright (C) 2015 by Lucas Cerveró Beltrán_LLuc Brell_Hobbes

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Garrapatea License

Copiright (C) 2015 by Lucas Cerveró Beltrán_LLuc Brell_Hobbes

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.