Audio1

Download: audio1.zip

 

Mit dem Audio-Objekt werden hier zufällig ausgesuchte Töne abgespielt.


var Gitsound=function()
{
    //Alle MP3-Töne die im Ordner sounds enthalten sind.
    this.toene=new Array("e0","f0","fis0","g0","gis0","a0","b0","h0","c1","cis1","d1","dis1","e1","f1","fis1","g1","gis1","a1","b1","h1","c2","cis2","d2","dis2","e2","f2","fis2","g2","gis2","a2","b2","h2","c3","cis3","d3","dis3","e3","f3","fis3","g3","gis3","a3","b3","h3","c4","cis4","d4","dis4","e4");
    //Array für bis zu 6 gleichzeitig spielbaren Sounds
    this.audiolist=new Array(new Audio(),new Audio(),new Audio(),new Audio(),new Audio(),new Audio());
    //Aktuelles Audioobjekt
    this.audionummer=0;
    this.tonzahl=0;
   
    this.zufallsound=function()
    {
        var z=Math.round(Math.random()*(this.toene.length-1));
        var ton = "sounds/"+this.toene[z] + ".mp3";
        this.audiolist[this.audionummer].src=ton;
        this.audiolist[this.audionummer].play();
        setdivtext("divtext",ton)
    }
     
    this.autosound=function()
    {
        if (this.audionummer>5){ this.audionummer=0; }
        var z=Math.round(Math.random()*(this.toene.length-1));
        var ton = "sounds/"+this.toene[z] + ".mp3";
        this.audiolist[this.audionummer].src=ton;
        this.audiolist[this.audionummer].play();
        this.audionummer++;
    }
   
 
    this.multisound=function()
    {
        this.autosound();
        this.tonzahl++;
        this.autosound();
        this.tonzahl++;
       
       
        if(this.tonzahl<40) 
        {
            setdivtext("divtext","Anzahl der gespielten Töne: "+this.tonzahl);
            setTimeout("gitsound.multisound()",500);
        }
        else
        {
            this.tonzahl=0;           
        }
    }
 
   
}//Ende der Klasse