HTML5 Web Audio Mudcube Piano Integration Composing Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

HTML5 Web Audio Mudcube Piano Integration Composing Tutorial

HTML5 Web Audio Mudcube Piano Integration Composing Tutorial

As promised in yesterdayโ€™s HTML5 Web Audio Mudcube Piano Integration Keyboard Tutorial as we left it with โ€ฆ

Next stop โ€œWork out a Protocol to Compose Chordsโ€, maybe, into the future โ€ฆ

โ€ฆ weโ€™re back to the future (tee hee) today. And in the spirit of โ€œI never promised you a Rose Gardenโ€ we had to settle for โ€œnear to music chordsโ€ with todayโ€™s endeavours. But look at it this way โ€ฆ you may have dodged a rose thorn bullet here!?

It is a personal favourite programming choice of ours to look for cute โ€œdelimitationโ€ solutions, an example being PHP Geo Map Google Chart Offset Tutorial. And one of our favourites is to add complexity by turning what used to be an integer data โ€œtypeโ€ into a float (ie. real number with decimal (fractional) parts called the โ€œmantissaโ€) data โ€œtypeโ€ (eg. starting with 60 as Middle C, and turning that into 60.048 for Middle C and an Octave C lower, or 60.048072 for Middle C and an Octave C lower and higher). Extra joy comes if that resultant โ€œnumberโ€ (covering both of those data types in scope) when โ€œroundedโ€ would result in the original โ€œintegerโ€ number anyway. Today we have such joy (because the highest note number of our piano is only 108 โ€ฆ much less than 499 even) as we allow the user to, within their textarea โ€œcomposing palletteโ€ now say that a โ€ฆ

normal number is a note (and mantissa sets of 3 characters (zero left padded) play notes close behind, like chords)

In order to make this happen we intervene where a composition takes Javascript variable form and encase that into a Javascript function return value โ€œmappingโ€ as per โ€ฆ



function abscissacheck(whatsm) {

// slowby4,51,-0.5,53,-0.5,51,-0.5,46,-0.5,51,-3.0,51,-0.5,53,-0.5,51,-0.5,53,-0.5,56,-0.5,53,-0.5,51,-0.5,53,-0.5,51,-0.5,46,-0.5,49,-3.0,61,-1.0,60,-0.5,56,-0.5,53,-1.0,51,-0.5,53,-0.5,51,-0.5,46,-0.5,51,-3.0,51,-0.5,53,-0.5,51,-0.5,53,-0.5,56,-0.5,53,-0.5,51,-0.5,53,-0.5,51,-0.5,46,-0.5,49,-3.0

var iout="", zdelim="", jou=0, jout="", kout="", newchordnote=0, xz="";

var xmididata=whatsm.split(',');

var atend=eval(-2 + xmididata.length);

var usual=true;

var ioffs=0;

showr=false;

if (xmididata[0].substring(0,1) >= 'A') {

ioffs=1;

kout=xmididata[0] + ",";

}

for (var iu=atend; iu>=ioffs; iu-=2) {

jout=iout;

if (jout != "") { zdelim=","; }

usual=true;

if (("" + xmididata[iu]).indexOf('.') != -1) { // a mantissa chord scenario

for (jou=0; jou<xmididata[iu].split('.')[1].length; jou+=3) {

xz=xmididata[iu].split('.')[1].substring(jou, eval(3 + jou))

if (xz.substring(0,1) == "0") {

newchordnote=eval('' + xz.substring(1));

if (usual) { iout=xmididata[iu].split('.')[0] + "," + xmididata[eval(1 + eval('' + iu))] + zdelim + jout; zdelim=","; jout=iout; }

usual=false;

} else {

newchordnote=eval('' + xz);

if (usual) { iout=xmididata[iu].split('.')[0] + "," + xmididata[eval(1 + eval('' + iu))] + zdelim + jout; zdelim=","; jout=iout; }

usual=false;

}

showr=true;

iout=newchordnote + "," + "-0.1" + zdelim + jout;

jout=iout;

zdelim=",";

//alert('' + newchordnote);

}

if (usual) { iout=xmididata[iu].split('.')[0] + "," + xmididata[eval(1 + eval('' + iu))] + zdelim + jout; }

} else {

iout=xmididata[iu] + "," + xmididata[eval(1 + eval('' + iu))] + zdelim + jout;

}

}

jout=iout;

if (kout != "") { iout=kout + jout; }

showr=false;

if (showr) { alert(iout.slice(-100)); }

return iout;

}





function insong(sheetmusic) { // assumes comma separators

if (sheetmusic != "") {

// add a suffix of + if two hands are playing together

// normal word is a speed descriptor

// normal number is a note (and mantissa sets of 3 characters (zero left padded) play notes close behind, like chords)

// -1 is crotchet, -2 is minum, -0.5 is quaver, -0.25 is semi-quaver etcetera

// 0 (alone) is for a rest of the duration above

// 0127 is normal loudness, etcetera

var done="", offset=0.0, offset2=0.0, planbit="", isrest=false, delaydelim='', notedelim='', curnote=-1, curvelocity=127, curdelay=-1, jk, ijk, prevvelocity=-1, prefix="", curval=1, kji=0, allhhh, bitshhbefore, notes, curnotes="", delays, curdelays="";

var plan=" MIDI.loadPlugin({ \n";

// etcetera etcetera etcetera




var mididata=abscissacheck(sheetmusic).split(',');

// etcetera etcetera etcetera

}

// etcetera etcetera etcetera

}

โ€ฆ for transcribed music or brand new compositions like (the new three octave version of Merry Christmas, Mr Lawrence theme) โ€ฆ

So feel free to try thechanged MyScaleโšซhtml liveโœ‚run link (supervising thechanged MyScaleโšซphp).

Did you know?

Looking for a real app that works with composing and sheet music? Weโ€™ve tried and would highly recommend the brilliant Sibelius.



Previous relevant HTML5 Web Audio Mudcube Piano Integration Keyboard Tutorial is shown below.

HTML5 Web Audio Mudcube Piano Integration Mobile Keyboard Tutorial

HTML5 Web Audio Mudcube Piano Integration Keyboard Tutorial

The web application of HTML5 Web Audio Mudcube Piano Integration Mobile Debug Tutorial makes minimal use of the keyboard, though it can be used for โ€œcomposingโ€ your own musical works into a textarea element. โ€œWhile you see a chance, take itโ€ โ€ฆ and so this could be an โ€œonions of the fourth dimensionโ€ moment for this web application โ€ฆ

  • for non-mobile platforms (where the keyboard is that independent thaing, whereas on mobile, it interferes with web application workflows) โ€ฆ because it facilitates โ€ฆ
  • the chance to play multiple notes (almost) at the same time โ€ฆ as per a musical chord

โ€ฆ for all practical purposes, an important thing youโ€™d want to be able to do with a piano playing web application (sadly only for non-mobile platforms).

And so, weโ€™re using characters from the Ascii table โ€ฆ

  • the numbers 1 through to 7 โ€ฆ and โ€ฆ
  • the letters A through to W uppercase โ€ฆ and โ€ฆ
  • the letters a through to w lowercase โ€ฆ for the piano ivory (white) keys โ€ฆ
  • ahead of corresponding key above for an associated sharp click the Ctrl or Control key โ€ฆ for the piano ebony (black) keys

โ€ฆ to cover the needs for a keyboard method of reaching all 87 piano keys of interest on our (online digital) piano, as per โ€ฆ



var kqueue=[], ikqueue=-1;

var eioisaltKey=false;

var eioisctrlKey=false;

var okn='';




function keyb(eiois) {

if (eiois.ctrlKey) {

eioisctrlKey=true;

} else if (eiois.altKey) {

eioisaltKey=true;

} else if ( eiois.keyCode == 17 ) {

eioisctrlKey=true;

} else if ( (eiois.which || eiois.keyCode) == 8 ) {

if (okn.length > 0) {

okn=okn.substring(0, eval(-1 + okn.length));

} else {

okn='';

}

if (eioisctrlKey) {

eioisctrlKey=false;

} else if (eioisaltKey) {

eioisaltKey=false;

}

} else if (eioisctrlKey) {

if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'A' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'G') {

kqueue.push("document.getElementById('N" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'a' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'g') {

kqueue.push("document.getElementById('o" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'H' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'N') {

kqueue.push("document.getElementById('N" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'h' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'n') {

kqueue.push("document.getElementById('o" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'O' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'U') {

kqueue.push("document.getElementById('N" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'o' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'u') {

kqueue.push("document.getElementById('o" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= '1' && String.fromCharCode(eiois.which || eiois.keyCode) <= '7') {

kqueue.push("document.getElementById('N" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'V' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'X') {

kqueue.push("document.getElementById('N" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

}

okn+=String.fromCharCode(eiois.which || eiois.keyCode) + '#';

if (eioisctrlKey) {

eioisctrlKey=false;

} else if (eioisaltKey) {

eioisaltKey=false;

}

} else {

if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'A' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'G') {

kqueue.push("document.getElementById('P" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'a' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'g') {

kqueue.push("document.getElementById('q" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'H' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'N') {

kqueue.push("document.getElementById('P" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'h' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'n') {

kqueue.push("document.getElementById('q" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'O' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'U') {

kqueue.push("document.getElementById('P" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'o' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'u') {

kqueue.push("document.getElementById('q" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= '1' && String.fromCharCode(eiois.which || eiois.keyCode) <= '7') {

kqueue.push("document.getElementById('P" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

} else if (String.fromCharCode(eiois.which || eiois.keyCode) >= 'V' && String.fromCharCode(eiois.which || eiois.keyCode) <= 'X') {

kqueue.push("document.getElementById('P" + String.fromCharCode(eiois.which || eiois.keyCode) + "').click();");

}

okn+=String.fromCharCode(eiois.which || eiois.keyCode);

if (eioisctrlKey) {

eioisctrlKey=false;

} else if (eioisaltKey) {

eioisaltKey=false;

}

}

if (ikqueue == -1 && kqueue.length > 0) {

ikqueue=0;

setTimeout(keychecking, 20);

}

}





function keychecking() {

var iok=-1, cok='';

if (kqueue.length > 0) {

for (var jkl=0; jkl<kqueue.length; jkl++) {

if (iok == -1 && kqueue[jkl] != '') {

iok=jkl;

}

}

if (iok != -1) {

cok=kqueue[iok];

kqueue[iok]='';

eval(cok);

setTimeout(keychecking, 20);

} else {

kqueue=[];

ikqueue=0;

setTimeout(keychecking, 20);

}

} else {

setTimeout(keychecking, 20);

}

}





setTimeout(andthenmode, 2000);

</script>

</head>

<body style='background-color: yellow;' onkeydown='prekeyb(event);' onkeypress='keyb(event);'>

Try thechanged MyScaleโšซhtml liveโœ‚run link.

Next stop โ€œWork out a Protocol to Compose Chordsโ€, maybe, into the future โ€ฆ and beyond.


Previous relevant HTML5 Web Audio Mudcube Piano Integration Mobile Debug Tutorial is shown below.

HTML5 Web Audio Mudcube Piano Integration Mobile Debug Tutorial

HTML5 Web Audio Mudcube Piano Integration Mobile Debug Tutorial

Yesterdayโ€™s HTML5 Web Audio Mudcube Piano Integration Tutorial was tested on non-mobile platforms, but with mobile (iOS) work we sometimes reach different parts of the Javascript client code, the reason being that the non-mobile platforms do not require that โ€œbutton touch eventโ€ intervention, and they can just go ahead and load any Web Audio functionality parts during the webpage onload period, and use it or not, at leisure. We noticed yesterday, โ€œno goโ€ for an iPad, which almost certainly means โ€œno goโ€ for iPhone as well. What to do? Similar to HTML5 Web Audio Piano Mobile Safari Web Inspector Debug Tutorial as per โ€ฆ

Did you notice the use of โ€ฆ anyone, anyone? โ€ฆ yes, Augusta Ada King โ€ฆ console.log([message]) calls all over the place. Could it be that โ€œalertโ€ calls would be too disruptive? Thatโ€™s right. Do you remember, perhaps, in science at school, how we learnt that looking at a photon was difficult because we would be interfering in how that photon would be in nature, and so we can not conclude anything categorically because of our interference. Well, โ€œtiming issuesโ€ are a bit the same, but console.log([message]) calls will not interfere and yet pass on information to โ€ฆ anyone, anyone? โ€ฆ yes, Grace Brewster Murray Hopper โ€ฆ a web inspector. Like Safariโ€™s we think, given weโ€™re working with โ€ฆ

  • an iPhone to test on
  • a MacBook Pro to facilitate the testing โ€ฆ connected via โ€ฆ
  • (the ubiquitous Apple white) lead โ€ฆ hardware wise โ€ฆ and โ€ฆ
  • the Safari web browser (on both devices, running our โ€œpiano web applicationโ€ on the iPhone Safari web browser) โ€ฆ software wise โ€ฆ and within that browserโ€™s โ€ฆ
  • Developer menu can get us to (the iPhone incarnation of the) Web Inspector โ€ฆ within which the โ€ฆ
  • Console tab can show us errors and warnings and information (which we can augment ourselves via our console.log[message]) Javascript DOM calls in the HTML/Javascript/CSS code of our โ€œpiano web applicationโ€ and its โ€œweb audio interfacingโ€ friend

โ€ฆ but if youโ€™ve not done this in the past โ€ฆ yes we have thanks โ€ฆ

โ€ฆ except, today, โ€œan iPhone and iPad to test onโ€. We found a few problems that the fixes for, allowed the Web Audio option for the piano web application to start working on the iPad and iPhone, for the โ€œcomposingโ€ parts as well.

And you can see us doing a bit of this with todayโ€™s animated GIF presentation.

Again, here are todayโ€™s mobile platform debugging changes โ€ฆ


Previous relevant HTML5 Web Audio Mudcube Piano Integration Tutorial is shown below.

HTML5 Web Audio Mudcube Piano Integration Tutorial

HTML5 Web Audio Mudcube Piano Integration Tutorial

The integrations of the recent HTML5 Web Audio Piano Mobile Safari Web Inspector Debug Tutorial have a lot in common with todayโ€™s โ€ฆ

  • audio applicability โ€ฆ in conjunction with โ€ฆ
  • piano

โ€ฆ basis. But this integration to an older โ€œpiano applicationโ€ incarnation, that used MIDI interfacing, has additional โ€œcomposingโ€ functionality weโ€™re keen to โ€œlassooโ€ into the integrations, because the integration of Web Audio will mean we can compose music on mobile platforms (we hope by tomorrow), if thatโ€™s your preference. On this front, do you remember us working out the haunting and beautiful theme to the music to Merry Christmas, Mr Lawrence when we presented HTML/Javascript/PHP Compose Music Makeover Tutorial โ€ฆ as per โ€ฆ

What was some of the inspiration? Right near the end of ABC Radio 702โ€™s Thu 27 Dec 2018, 6:00am Sydney, Australia podcast you can hear what was to me a captivating piano solo played by Ryuichi Sakamoto below โ€ฆ


โ€ฆ written for the movie Merry Christmas, Mr Lawrence.

? Well, weโ€™ve used that tune to test run our integration, where it wasnโ€™t just the case of plugging in the same logic of the integration of HTML5 Web Audio Piano Mobile Safari Web Inspector Debug Tutorial, alas. The MIDI plugin of the mudcube incarnation does some clever client โ€œsleepingโ€ to do its thaing, so we have to work out quite a bit of setTimeout (timer) rearranging to simulate those โ€œsmartsโ€.

Here are the changes โ€ฆ

โ€ฆ for transcribed music or brand new compositions like โ€ฆ

โ€ฆ with which we hope you might now be able to work music compositions (at least on non-mobile for today), via the Web Audio API that came in with HTML5.


Previous relevant HTML5 Web Audio Piano Mobile Safari Web Inspector Debug Tutorial is shown below.

HTML5 Web Audio Piano Mobile Safari Web Inspector Debug Tutorial

HTML5 Web Audio Piano Mobile Safari Web Inspector Debug Tutorial

There were problems peculiar to mobile platforms involved in the work of yesterdayโ€™s HTML5 Web Audio Piano Mobile Tutorial. But just how did we arrive at a solution? We can tell you now a placement of Javascript โ€œalertโ€ popup windows is inadequate for such an involved issue that cannot be simulated on our usual MacBook Pro laptop โ€œhome baseโ€ computer. So what to do?

Thereโ€™s a big clue in the difference reports of yesterday โ€ฆ

Did you notice the use of โ€ฆ anyone, anyone? โ€ฆ yes, Augusta Ada King โ€ฆ console.log([message]) calls all over the place. Could it be that โ€œalertโ€ calls would be too disruptive? Thatโ€™s right. Do you remember, perhaps, in science at school, how we learnt that looking at a photon was difficult because we would be interfering in how that photon would be in nature, and so we can not conclude anything categorically because of our interference. Well, โ€œtiming issuesโ€ are a bit the same, but console.log([message]) calls will not interfere and yet pass on information to โ€ฆ anyone, anyone? โ€ฆ yes, Grace Brewster Murray Hopper โ€ฆ a web inspector. Like Safariโ€™s we think, given weโ€™re working with โ€ฆ

  • an iPhone to test on
  • a MacBook Pro to facilitate the testing โ€ฆ connected via โ€ฆ
  • (the ubiquitous Apple white) lead โ€ฆ hardware wise โ€ฆ and โ€ฆ
  • the Safari web browser (on both devices, running our โ€œpiano web applicationโ€ on the iPhone Safari web browser) โ€ฆ software wise โ€ฆ and within that browserโ€™s โ€ฆ
  • Developer menu can get us to (the iPhone incarnation of the) Web Inspector โ€ฆ within which the โ€ฆ
  • Console tab can show us errors and warnings and information (which we can augment ourselves via our console.log[message]) Javascript DOM calls in the HTML/Javascript/CSS code of our โ€œpiano web applicationโ€ and its โ€œweb audio interfacingโ€ friend

โ€ฆ but if youโ€™ve not done this in the past, there is a fair bit to do to get up and running doing this. In setting this up, we were stuck for a while with connections but blank console tab screens. Why? Well, you need both iPhone and MacBook Pro to have any outstanding operating system updates attended to. Then, given that, weโ€™d recommend following the excellent advice of How to Activate the iPhone Debug Console, thanks โ€ฆ

On the iPhone (setting up wise) โ€ฆ

  1. Tap the Settings icon on the iPhone Home screen.
  2. Scroll down until you reach Safari and tap on it to open the screen that contains everything related to the Safari web browser on your iPhone, iPad, or iPod touch.
  3. Scroll to the bottom of the screen and tap Advanced menu.
  4. Toggle the slider next to Web Inspector to the On position.

On the MacBook Pro (setting up wise) โ€ฆ

  1. Click Safari in the menu bar and choose Preferences.
  2. Click the Advanced tab
  3. Select the box next to Show Develop menu in menu bar.
  4. Exit the settings window.
  5. Click Develop in the Safari menu bar and select Show Web Inspector.

โ€ฆ and weโ€™ve got for you some screenshots of our โ€œgoings onโ€ sorting out our โ€œpiano web applicationโ€ problems on mobile (at least iOS) platforms with todayโ€™s PDF โ€œstream of consciousnessโ€ presentation. We hope it helps you out, or gets you down the road of digging into an issue you have with an HTML web application on an iOS device.


Previous relevant HTML5 Web Audio Piano Mobile Tutorial is shown below.

HTML5 Web Audio Piano Mobile Tutorial

HTML5 Web Audio Piano Mobile Tutorial

You guessed it! The software integrations of yesterdayโ€™s HTML5 Web Audio Piano Tutorial had issues with the mobile platforms. Do fish swim? Do axolotl have two Lโ€™s and two Oโ€™s? Yes, yes and yes.

With our iPad and iPhone testing (and weโ€™ll go more into that tomorrow) we found timing issues as to when exactly to call that window onload init function. Which beggars the question, being that window and document are two different objects of a webpage โ€œis window onload the same as document body onload?โ€ Weโ€™d always assumed so, and trying โ€œnot to be in that bubble of our own existenceโ€, did read at least the first link of that previous Google search to feel appeased. It seems so โ€ฆ but we digress.

Why is this timing important? As weโ€™ve said many times, Appleโ€˜s iOS (mobile operating system) and audio are super sensitive to trying to eradicate โ€œsounds on (webpage) loadโ€, we take it, and want to only allow for audio easily via a โ€œtouchโ€ event off a button (made by a human โ€ฆ and, we hope, all axolotls), thatโ€™s why. Get the timing wrong, and we werenโ€™t, on mobile platforms, creating the buttons needed to touch in order to make the 87 different notes on our piano.

This work is accessible via thechanged pianoโšซhtmโ€˜s pianoโœ‚web application calling on thechanged web_audioโšซhtm (Web Audio API interfacer) in an iframe.


Previous relevant HTML5 Web Audio Piano Tutorial is shown below.

HTML5 Web Audio Piano Tutorial

HTML5 Web Audio Piano Tutorial

We find software integration interesting yet challenging, and the integration of โ€ฆ

โ€ฆ in these early days, before we give up on the mobile platform issue compromises we have so far, is no exception.

In broad brush terms we โ€ฆ

  • call from thechanged pianoโšซhtmโ€˜s pianoโœ‚web application thechanged web_audioโšซhtm (Web Audio API interfacer) in an iframe as per (the HTML) โ€ฆ


    <iframe class=ask title='versus Audio Web' frameborder=0 scrolling='no' style='overflow:hidden;background-color:orange;display:inline-block;width:500px;height:28px;max-height:28px;' width=500 height=28 src='web_audio.htm?vscaseyrule=y'></iframe>


    โ€ฆ and so in โ€ฆ
  • web_audio.htm (it) creates up above all else in the top left corner of its webpage, on detecting this call above โ€ฆ


    <script type='text/javascript'>

    if ((location.search.split('vscaseyrule=')[1] ? (' ' + decodeURIComponent(location.search.split('vscaseyrule=')[1]).split('&')[0]) : '') != '') { //navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {

    var hish='<div class=parent id=dchoose style="font-size:26px;position:absolute;top:0px;left:0px;z-index:2001;display:inline-block;background-color:transparent;"><input class=child placeholder="CaseyRule" title="versus Audio Web" style="position:absolute;top:0px;left:0px;z-index:2001;display:inline-block;background-color:transparent;" name=dlhuhb id=dlhuhb onchange="' + "actedupon=true; this.visibility='visible'; parent.document.getElementById('conduit').value=' '; parent.document.getElementById('cmdconduit').value=' '; document.getElementById('dchoose').innerHTML='Web Audio'; " + '" onclick="actedupon=true; parent.document.getElementById("' + "conduit" + '").value=String.fromCharCode(32); parent.document.getElementById("' + "cmdconduit" + '").value=String.fromCharCode(32); setTimeout(init,1500);" onblur="actedupon=true; parent.document.getElementById("' + "conduit" + '").value=String.fromCharCode(32); parent.document.getElementById("' + "cmdconduit" + '").value=String.fromCharCode(32); this.value=' + "'Web Audio';" + ' setTimeout(init,1800);" ontouchstart=" parent.document.getElementById("' + "conduit" + '").value=String.fromCharCode(32); parent.document.getElementById("' + "cmdconduit" + '").value=String.fromCharCode(32); setTimeout(init,500);" list="modes" name="modes"><datalist id="modes"><option value="CaseyRule"><option value="Audio Web"></datalist></div>';

    if (1 == 1 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {

    hish='<div class=parent id=dchoose style="font-size:26px;position:absolute;top:0px;left:0px;z-index:2001;display:inline-block;background-color:transparent;">CaseyRule versus <button style=display:inline-block;background-color:red; id=dlhuhb onmousedown="' + "actedupon=true; parent.document.getElementById('conduit').value=' '; parent.document.getElementById('cmdconduit').value=' '; this.innerHTML=''; setTimeout(init,500);" + '" ontouchstart="' + "actedupon=true; parent.document.getElementById('conduit').value=' '; parent.document.getElementById('cmdconduit').value=' '; setTimeout(init,200);" + '">Web Audio</button></div>';

    }

    document.write(hish);

    }

    </script>


    โ€ฆ a default piano โ€œCaseyRuleโ€ mode of use piece of text, followed by a HTML button element โ€œWeb Audioโ€ to switch to that โ€ฆ and back at โ€ฆ
  • piano.htm detects a โ€œWeb Audioโ€ mode of use when that โ€ฆ


    if (document.getElementById('conduit').value != '') {

    document.getElementById('cmdconduit').value+="parent.document.getElementById('iaudio" + caboffrank + "').src='" + what + "'; ";

    document.getElementById('conduit').value+=what.replace('/','').replace('.','') + ' ';

    } else {

    document.getElementById('iaudio' + caboffrank).src=what;

    }


    โ€ฆ document.getElementById(โ€˜conduitโ€™).value is not โ€ because it is storing button press information for โ€ฆ
  • web_audio.htm to play the audio off that button press via โ€ฆ


    function pianonoteplay(bo) {

    var ioth='' + eval('' + bo.title);

    var prefix="";

    if (!nostop) { stopit(); } else { lastbo=null; }

    if (whichs == "") { whichs="" + ioth; }

    whichs="" + eval(ioffs[eval(-1 + eval('' + ioth))] + eval(ioth));

    if (sourcep_valid()) { //if (typeof sourcep !== 'undefined') {

    sourcep[eval(-1 + eval(whichs))]=true;

    } else {

    eval("source" + whichs + "p=true;");

    }

    var sendb=("(" + document.getElementById('startingin').value + "," + document.getElementById('startingat').value + ");").replace("(,)", "(0)").replace("(,", "(0,").replace(",)", ",0)");

    var suffix=("(" + document.getElementById('startingin').value + "," + document.getElementById('startingat').value + ")").replace("(,)", "").replace("(0,0)", "").replace("(0,)", "").replace("(,0)", "").replace("(,", ",").replace(",)", "").trim();

    if (source_valid()) { //if (typeof source !== 'undefined') {

    if (fors.replace('0','') != '' && fors.indexOf('-') == -1) {

    source[eval(-1 + eval(whichs))].start(eval('0' + document.getElementById('startingin').value), eval('0' + document.getElementById('startingat').value), eval('' + dura(document.getElementById('duration').value,lastbo).split(';')[0].split(':')[eval(-1 + dura(document.getElementById('duration').value,lastbo).split(';')[0].split(':').length)].split('.')[0].split(' ')[0]));

    } else if (document.getElementById('duration').value.replace('0','') != '') {

    source[eval(-1 + eval(whichs))].start(eval('0' + document.getElementById('startingin').value), eval('0' + document.getElementById('startingat').value), eval('' + dura(document.getElementById('duration').value,lastbo).split(';')[0].split(':')[eval(-1 + dura(document.getElementById('duration').value,lastbo).split(';')[0].split(':').length)].split('.')[0].split(' ')[0]));

    } else {

    source[eval(-1 + eval(whichs))].start(eval('0' + document.getElementById('startingin').value), eval('0' + document.getElementById('startingat').value));

    }

    } else {

    eval("source" + whichs + ".start" + dura(sendb,lastbo));

    }

    nostop=false;

    document.getElementById('startingat').value='';

    document.getElementById('startingin').value='';

    document.getElementById('loop1').checked=false;

    document.getElementById('loop2').checked=false;

    checknext();

    ioffs[eval(-1 + eval(ioth))]+=four;

    ioffset=ioffs[eval(-1 + eval(ioth))];

    if (sourcep_valid()) { //if (typeof sourcep !== 'undefined') {

    sourcep[eval(-1 + eval(ioffset + eval(ioth)))]=false;

    } else {

    eval("source" + eval(ioffset + eval(ioth)) + "p=false;");

    }

    if (source_valid()) { //if (typeof source !== 'undefined') {

    source[eval(-1 + eval(ioffset + eval(ioth)))] = context.createBufferSource();

    source[eval(-1 + eval(ioffset + eval(ioth)))].buffer = sb[eval(-1 + eval(ioth))];

    source[eval(-1 + eval(ioffset + eval(ioth)))].connect(context.destination);

    } else {

    eval("source" + eval(ioffset + eval(ioth)) + " = context.createBufferSource(); source" + eval(ioffset + eval(ioth)) + ".buffer = sb[" + eval(-1 + eval(ioth)) + "]; source" + eval(ioffset + eval(ioth)) + ".connect(context.destination); ");

    }

    }

โ€ฆ for starters.

Expecting a sound tonality difference between the methods? No, a computer creates the sound the same way via the same sound frequency, and if the response time is reasonable we couldnโ€™t hear big rhythm changes that you might expect with the parent/child โ€œchatterโ€ required for all this.

Feel free to try your piano playing scales and arpeggios and chords with todayโ€™s more integrated liveโœ‚run link.


Previous relevant HTML5 Web Audio Mobile Tutorial is shown below.

HTML5 Web Audio Mobile Tutorial

HTML5 Web Audio Mobile Tutorial

There is another two pronged improvement approach again today building on HTML5 Web Audio Overlay Tutorialโ€˜s two pronged approach to the previous two pronged approach โ€ฆ which makes for a great fork for spaghetti but we digress โ€ฆ the prongs today being โ€ฆ

  • first, and like yesterday, allow for clientside HTML to do what serverside PHP usually does for us โ€ฆ handle large amounts of data as PHP can do using its $_POST[] approach โ€ฆ weโ€™re still calling โ€œOverlay Iframe Rememberingโ€ โ€ฆ and add to โ€ฆ
    1. child iframe src= mode of use โ€ฆ but also with, new to today โ€ฆ
    2. child iframe srcdoc= mode of use

    โ€ฆ because (am not absolutely sure why as yet but) it solves the problem with โ€ฆ
    โ€ฆ non-mobile/Safari/fill in โ€œAudio Contentโ€ form/including a Duration/click โ€œWeb Audio Runโ€ button โ€ฆ
    โ€ฆ didnโ€™t automatically start any audio, though other non-mobile web browsers do โ€ฆ
    โ€ฆ and as you may imagine this needs some delimitation explanations that show below โ€ฆ


    function takealook(fo) {

    var noneed=true;

    var htmlis='';

    var nsuffix='';

    if (document.getElementById('url1').value.length > 500) { noneed=false; }

    if (document.getElementById('url2').value.length > 500) { noneed=false; }

    if (document.getElementById('url3').value.length > 500) { noneed=false; }

    if (document.getElementById('url4').value.length > 500) { noneed=false; }

    if (document.getElementById('durationget').value.length > 0) { nsuffix='ยฌoka=secret'; noneed=false; } else { isrc=' src='; }

    if (source_valid()) {

    if (noneed) { return true; }

    if (isrc == ' srcdoc=') {

    if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {

    document.getElementById('huhb').style.display='inline-block';

    document.getElementById('diframe').innerHTML="<iframe id=myi style='opacity:1.0;position:absolute;top:0px;left:0px;z-index:-" + eval(1 + eval('0' + zi)) + ";width:100%;height:100vh;' srcdoc=></iframe>";

    } else {

    document.getElementById('diframe').innerHTML="<iframe id=myi style='opacity:1.0;position:absolute;top:0px;left:0px;z-index:-" + eval(1 + eval('0' + zi)) + ";width:100%;height:100vh;' srcdoc=></iframe>";

    }

    if (documentURL.indexOf('#') == -1) { document.getElementById('divbody').style.opacity='1.0'; }

    document.getElementById('myi').srcdoc='<!doctype html><html><head>' + document.head.innerHTML.replace(/document\.URL/g,"'" + documentURL.split('#')[0].split('?')[0] + "?zi=" + eval(1 + eval('0' + zi)) + nsuffix + "ยฌoka=" + encodeURIComponent(notoka.trim()) + "'").replace(/\'0\.2\'/g,"'1.0'") + '</head><body>' + document.body.innerHTML.replace(/document\.URL/g,"'" + documentURL.split('#')[0].split('?')[0] + "?zi=" + eval(1 + eval('0' + zi)) + nsuffix + "ยฌoka=" + encodeURIComponent(notoka.trim()) + "'").replace(/\'0\.2\'/g,"'1.0'") + '</body></html>';

    } else {

    if (documentURL.indexOf('#') == -1) { document.getElementById('divbody').style.opacity='0.2'; }

    document.getElementById('diframe').innerHTML="<iframe style='position:absolute;top:0px;left:0px;z-index:" + eval(1 + eval('0' + zi)) + ";width:100%;height:100vh;' src='" + documentURL.split('#')[0].split('?')[0] + "?zi=" + eval(1 + eval('0' + zi)) + nsuffix + "'></iframe>";

    }

    } else {

    if (notoka.trim().toLowerCase() == 'secret') { noneed=false; }

    if (noneed) { return true; }

    if (isrc == ' srcdoc=') {

    if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {

    document.getElementById('huhb').style.display='inline-block';

    document.getElementById('diframe').innerHTML="<iframe id=myi style='opacity:1.0;position:absolute;top:0px;left:0px;z-index:-" + eval(1 + eval('0' + zi)) + ";width:100%;height:100vh;' srcdoc=></iframe>";

    } else {

    document.getElementById('diframe').innerHTML="<iframe id=myi style='opacity:1.0;position:absolute;top:0px;left:0px;z-index:-" + eval(1 + eval('0' + zi)) + ";width:100%;height:100vh;' srcdoc=></iframe>";

    }

    if (documentURL.indexOf('#') == -1) { document.getElementById('divbody').style.opacity='1.0'; }

    document.getElementById('myi').srcdoc='<!doctype html><html><head>' + document.head.innerHTML.replace(/document\.URL/g,"'" + documentURL.split('#')[0].split('?')[0] + "?zi=" + eval(1 + eval('0' + zi)) + "ยฌoka=" + encodeURIComponent(notoka.trim()) + "'").replace(/\'0\.2\'/g,"'1.0'") + '</head><body>' + document.body.innerHTML.replace(/document\.URL/g,"'" + documentURL.split('#')[0].split('?')[0] + "?zi=" + eval(1 + eval('0' + zi)) + "ยฌoka=" + encodeURIComponent(notoka.trim()) + "'").replace(/\'0\.2\'/g,"'1.0'") + '</body></html>';

    } else {

    if (documentURL.indexOf('#') == -1) { document.getElementById('divbody').style.opacity='0.2'; }

    document.getElementById('diframe').innerHTML="<iframe style='position:absolute;top:0px;left:0px;z-index:" + eval(1 + eval('0' + zi)) + ";width:100%;height:100vh;' src='" + documentURL.split('#')[0].split('?')[0] + "?zi=" + eval(1 + eval('0' + zi)) + "ยฌoka=" + encodeURIComponent(notoka.trim()) + "'></iframe>";

    }

    }

    return false;

    }


    โ€ฆ adding another option to โ€œOverlay Iframe Rememberingโ€ types of solutions, we figure โ€ฆ cute in the sense that all this is clientside HTML/Javascript/CSS

  • โ€ฆ as per theseinterim changes

  • mobile platform considerations (in our tests of iOS iPad and iPhone) โ€ฆ
    1. allowing for a button press โ€œtouchโ€ event (โ€œtouchstartโ€ for us, but read somewhere that they liked โ€œtouchendโ€) to trigger the AudioContext setup
    2. taking away the โ€œcaptureโ€ property of our browser buttons so that the mobile platform user can browse for an existant media file or capture that media
    3. we try to allow video media to be played in that video element should the user choose a video media file as their audio media choice which tends to be the way for the โ€œcaptureโ€ property of a mobile user input type=file browser button

    โ€ฆ as per thesechanges

Did you get from the code snippets how this โ€œOverlay Iframe Rememberingโ€ works by storing the large amounts of data in an overlayed โ€œlayerโ€ of webpage, both webpage layers โ€œclientsideโ€ by nature and available datawise to each other in a parent/child (layer1WebpageParent/layer2OverlayedIframeWebpageChild) arrangement, that iframe being populated via a src= scenario getting the โ€œoverlayโ€ to populate itself or help that โ€œoverlayโ€ along (perhaps itโ€™s that period after lunch digesting the caviar?!) by supplying its content via srcdoc= usage? Again, perhaps it is easier to see it in action at thisโœ‚live run link.


Previous relevant HTML5 Web Audio Overlay Tutorial is shown below.

HTML5 Web Audio Overlay Tutorial

HTML5 Web Audio Overlay Tutorial

Again, in building on yesterdayโ€™s HTML5 Web Audio Duration Tutorial two pronged approach, we have another one today, those approaches involving โ€ฆ

  • first allow for clientside HTML to do what serverside PHP usually does for us โ€ฆ handle large amounts of data as PHP can do using its $_POST[] approach โ€ฆ weโ€™re going to call โ€œOverlay Iframe Rememberingโ€ โ€ฆ whereby the
    1. navigational form gets a new id=waform onsubmit=โ€™return takealook(this);โ€™ โ€ฆ


      function takealook(fo) {

      var noneed=true;

      var nsuffix='';

      if (document.getElementById('url1').value.length > 500) { noneed=false; }

      if (document.getElementById('url2').value.length > 500) { noneed=false; }

      if (document.getElementById('url3').value.length > 500) { noneed=false; }

      if (document.getElementById('url4').value.length > 500) { noneed=false; }

      if (document.getElementById('durationget').value.length > 0) { nsuffix='ยฌoka=secret'; noneed=false; }

      if (source_valid()) {

      if (noneed) { return true; }

      document.getElementById('divbody').style.opacity='0.2';

      document.getElementById('diframe').innerHTML="<iframe style='position:absolute;top:0px;left:0px;z-index:" + eval(1 + eval('0' + zi)) + ";width:100%;height:100vh;' src='" + document.URL.split('#')[0].split('?')[0] + "?zi=" + eval(1 + eval('0' + zi)) + nsuffix + "'></iframe>";

      } else {

      if (notoka.trim().toLowerCase() == 'secret') { noneed=false; }

      if (noneed) { return true; }

      document.getElementById('divbody').style.opacity='0.2';

      document.getElementById('diframe').innerHTML="<iframe style='position:absolute;top:0px;left:0px;z-index:" + eval(1 + eval('0' + zi)) + ";width:100%;height:100vh;' src='" + document.URL.split('#')[0].split('?')[0] + "?zi=" + eval(1 + eval('0' + zi)) + "ยฌoka=" + encodeURIComponent(notoka.trim()) + "'></iframe>";

      }

      return false;

      }


      โ€ฆ where if noneed ends up as false we perform some overlay favourites โ€ฆ building on โ€ฆ
    2. textbox HTML design changes from โ€ฆ


      <input style='display:inline-block;background-color:#f0f0f0;' type=text name=url2 title='Audio URL 2' value='./one_to_fiftynine.m4a'></input>


      โ€ฆ to โ€ฆ


      <input data-id=url2 onblur="document.getElementById(this.getAttribute('data-id')).value=this.value;" style='display:inline-block;background-color:#f0f0f0;' type=text name=url2 title='Audio URL 2' value='./one_to_fiftynine.m4a'></input>

      <div id=dform style='display:none;'></div>

      <div id=diframe></div>


      โ€ฆ that makes the document.body onload logic below be useful for the context of that onsubmit form logic above โ€ฆ


    3. document.getElementById('dform').innerHTML=document.getElementById('waform').innerHTML.replace(/\ data\-id=/g, ' id=').replace(/\ onblur=/g, ' data-onblur=');

    โ€ฆ as per theseinterim changes โ€ฆ then in the context of those large amounts of data possibly coming from โ€ฆ

  • like with the recent Video via Canvas File API Tutorial โ€ฆ

    โ€ฆ we see for web applications, two primary source โ€œpartitionsโ€, those being โ€ฆ

    • around the โ€œnetโ€ (in the server wooooooorrrrrlllllld, in the public areas of the Internet, which are not in โ€œthe dark webโ€, that is) via an absolute URL (to the same domain or beyond) and/or relative URL (in relation to the URL โ€œhomeโ€ place on the web server of the same domain as where you launched it โ€ฆ which we catered for yesterday, though quietly weโ€™d have allowed absolute URLs too, itโ€™s just that cross-domain restrictions make us shy about publicizing that) โ€ฆ versus โ€ฆ
    • on the client computer (or device)

    โ€ฆ and, yes, for all those who guessed weโ€™d try to cater for image and/or video data coming from this client source, you are correct โ€ฆ

    โ€ฆ media file browsing, via the wonderful File API, additional functionality as per thesechanges to web_audioโšซhtm

Did you get from the code snippets how this โ€œOverlay Iframe Rememberingโ€ works by storing the large amounts of data in an overlayed โ€œlayerโ€ of webpage, both webpage layers โ€œclientsideโ€ by nature and available datawise to each other in a parent/child (layer1WebpageParent/layer2OverlayedIframeWebpageChild) arrangement? Perhaps it is easier to see it in action at thisโœ‚live run link.


Previous relevant HTML5 Web Audio Duration Tutorial is shown below.

HTML5 Web Audio Duration Tutorial

HTML5 Web Audio Duration Tutorial

In building on yesterdayโ€™s HTML5 Web Audio Primer Tutorial we adopted a two pronged approach, that being โ€ฆ

โ€ฆ that we welcome you to try at this liveโœ‚run link.


Previous relevant HTML5 Web Audio Primer Tutorial is shown below.

HTML5 Web Audio Primer Tutorial

HTML5 Web Audio Primer Tutorial

As an audio/video synchronization alternative to the techniques used in Mac OS X Text to English Speech Primer Tutorial, today, we involve the great Web Audio API functionality introduced with HTML5 and โ€œstarringโ€ in HTML5 Rocksโ€™s Getting Started with Web Audio API great advice on this subject.

We start down this long road, we suspect, being able to โ€ฆ

  • set up the audio playing of four separate audio sources (some featuring in Spliced Audio Number Genericization Tutorial) โ€ฆ where โ€ฆ
  • one, with its default configuration, synchronizes with an apt video media play
  • allow looping
  • allow for โ€œstart atโ€ seconds
  • allow for โ€œstart inโ€ seconds

โ€ฆ on a first draft HTML and Javascript and CSS web_audioโšซhtml liveโœ‚run link.

We hope you hang around on our road trip with this topic.


Previous relevant Spliced Audio Number Genericization Tutorial is shown below.

Spliced Audio Number Genericization Tutorial

Spliced Audio Number Genericization Tutorial

If youโ€™ve completed a successful โ€œproof of conceptโ€ stage to a project, it can be tempting at this early stage, even before applying it to the specific intended software integration target, to consider ways to โ€œgenericizeโ€ that application, and so it is for us, here, with yesterdayโ€™s Spliced Audio Number Announcements Tutorial, as shown below, that we feel this could come along to be applied for other purposes. We have no doubt the exercise of doing this serves at least three good purposes โ€ฆ

  1. slow it down a bit before rushing to โ€œsoftware integrateโ€, as patience can be good here
  2. learn more about whatโ€™s possible, and what isnโ€™t, to do with the scope of your planning and thinking
  3. other application may, too, benefit from this โ€œearly daysโ€ โ€œgenericizationโ€ of a potential plugin component piece of HTML and Javascript code

In this early stage of โ€œgenericizationโ€ thoughts, we think that with our project we want to keep intact these ideas โ€ฆ

  • thereโ€™ll be up to 3 โ€œcolumnsโ€ of ideas to piece together an audio message from its constituent parts, like with those Sydney train platform announcements weโ€™ve talked about before
  • thereโ€™ll be 3 soundfiles mapped to most of the usage regarding these 3 โ€œcolumnsโ€
  • thereโ€™ll be the possibility for silence to be an option in each โ€œcolumnโ€
  • thereโ€™ll be the mechanism by which the user can define their own โ€œTitleโ€ and โ€œSubtitleโ€ and 3 โ€œcolumnโ€ headings themselves
  • thereโ€™ll be 2 leftmost โ€œcolumnsโ€ that define counting numbers whose ranges can be defined by the user, where, for now, the timing of sounds goes that sounds start at [number].4 seconds and plays for 1.5 seconds
  • thereโ€™ll be minimum and maximum special case entries available for user definition in the leftmost โ€œcolumnโ€ that calls on the fourth soundfile, where, for now, the timing of sounds goes that sounds start at 0 seconds and 2 seconds respectively and plays for 2 seconds
  • thereโ€™ll be a minimum special case entry available for user definition in the middle โ€œcolumnโ€ that calls on a sound from the third soundfile, where, for now, the timing of sounds goes that sounds start at 3.1 seconds and plays for 1.8 seconds
  • thereโ€™ll be 1 rightmost โ€œcolumnโ€ that can have three entries defined

And that is as far as we go with โ€œgenericizationsโ€, at this stage, with our project.

In our experience, what Javascript function is a big friend of โ€œgenericizationโ€? Weโ€™d say Javascript eval function is our favourite here.

Itโ€™s funny to think that our HTML and Javascript and CSS audio_1_59โšซhtm, vastly changed from yesterday as per thislink, functions exactly the same in its default form, and you can continue to enjoy its accompanying defaultโœ‚live run link, but it can, through the use of complex URLs (only, just at this early stage) be made to look quite different, with the same code, as you can see with this complexโœ‚live run.

So, in summary, this leaves us with many more โ€œlive runโ€ options, those being โ€ฆ


Previous relevant Spliced Audio Number Announcements Tutorial is shown below.

Spliced Audio Number Announcements Tutorial

Spliced Audio Number Announcements Tutorial

Weโ€™ve got a โ€œproof of conceptโ€ tutorial for you today, because weโ€™ve got an idea for something, as we said some time back at Splicing Audio Primer Tutorial โ€ฆ

The first was a simulation of those Sydney train public announcements where the timbre of the voice differs a bit between when they say โ€œPlatformโ€ and the โ€œ6โ€ (or whatever platform it is) that follows. This is pretty obviously computer audio โ€œbitsโ€ strung together โ€ฆ and wanted to get somewhere towards that capability.

โ€ฆ that will probably be blimminโ€™ obvious to you should you be a regular recent reader at this blog.

Do you remember what we, here, see as a characteristic of โ€œproof of conceptโ€ at WordPress Is Mentioned By Navigation Primer Tutorial โ€ฆ

To us, a โ€œproof of conceptโ€ is not much use if it is as involved as what it is trying to prove

โ€ฆ and do you remember how we observed at Windows 10 Cortana Primer Tutorial โ€ฆ

โ€ฆ because you can work Cortana without the voice recognition part, if you like, or if you have the urge to run for the nearest cupboard before being caught talking into a computer (microphone)

? Well, today, weโ€™d like you to be patient about the lack of audio quality with our home made audio (see excuse 2 above) bit we are mainly interested in โ€œproof of conceptโ€ issues (see excuse 1 above).

So what โ€œingredientsโ€ went into this โ€œAudio Numbersโ€ web application? As we did in Apple iOS Siri Audio Commentary Tutorial โ€ฆ

HTML audio elements that allow for an audio commentary of the 9 โ€œsubimagesโ€ โ€ฆ the content for which is derived on a Mac OS X by QuickTime Playerโ€˜s Audio Recording functionality, which we last talked about at this blog with QuickTime Player Video Flickr Share Primer Tutorial

โ€ฆ we do again today. On doing this we realized the recordings were not loud enough, so started down the road of R&D on this and got to the very useful Increase Audio Volume website tool that helped a little, and this manifests itself if/when you run our liveโœ‚run today, that if you pick โ€œminuteโ€ numbers less than or equal to โ€œ30โ€ they are a better better in volume than others, with the โ€œTrial Versionโ€ of this software helping you out with โ€œhalf fileโ€ enhancements. โ€œProof of conceptโ€, remember? And so the aspects youโ€™d change for your own purposes, are โ€ฆ

  1. the content (and more than likely, names) of audio files mentioned below โ€ฆ
  2. arrays of audio files โ€ฆ


    var audiomedia=["one_to_fiftynine.m4a","past_quarterto.m4a","am_pm.m4a"];

    var midmedia=["midnight_midday.m4a"];


    โ€ฆ and it should be noted here, that a separate file for each unique sound, could be a good alternative design, and would stop failures to do with the slow loading speed of the home web server causing audio misfiring โ€ฆ and would mean, below, that โ€œastartโ€ is always โ€œ0โ€ and โ€œdelayโ€ should be set to the audio objectโ€™s duration parameter
  3. variables โ€œastartโ€ and โ€œdelayโ€ as per example โ€ฆ


    } else if (thingis.toLowerCase().indexOf('clock') != -1) {

    oaudio.src=audiomedia[i];

    astart=eval("3.1");

    delay=1.8;



    โ€ฆ where โ€œastartโ€ reflects a start of play value and โ€œdelayโ€ represents a length of play scenario in seconds, as we got going in the past when we presented Spliced Audio/Video Overlay Position Tutorial as shown below, where you can read more about the HTML5 Audio objects we used with this โ€œproof of conceptโ€ project

Please note with the recording of โ€œone_to_fiftynine.m4aโ€, that records numbers from 1 to 59, via QuickTime Player, we relied on the recording timer, to time our number recording with a second of duration to make the HTML and Javascript coding a lot easier!

So, as you can see, this is โ€œproof of conceptโ€ preparation, and of you want to try it yourself, perhaps youโ€™d like to start with a skeleton of todayโ€™s HTML and Javascript audio_1_59โšซhtml as a starting point?!


Previous relevant Spliced Audio/Video Overlay Position Tutorial is shown below.

Spliced Audio/Video Overlay Position Tutorial

Spliced Audio/Video Overlay Position Tutorial

Today weโ€™ve written a third draft of an HTML and Javascript web application that splices up to nine bits of audio or video or image input together, building on the previous Spliced Audio/Video/Image Overlay Tutorial as shown below, here, and that can take any of the forms โ€ฆ

  • audio file โ€ฆ and less user friendly is โ€ฆ
  • text that gets turned into speech via Google Translate (and user induced Text to Speech functionality), but needs your button presses
  • video
  • image โ€ฆ and background image for webpage

โ€ฆ for either of the modes of use, that being โ€ฆ

  • discrete โ€ฆ or โ€œOptionalโ€
  • synchronized โ€ฆ or โ€œOverlayโ€

โ€ฆ all like yesterday, but this time we allow you to โ€œseekโ€ or position yourself within the audio and/or video media. We still all โ€œfitโ€ this into GET parameter usage. Are you thinking we are a tad lazy with this approach? Well, perhaps a little, but it also means you can do this job just using clientside HTML and Javascript, without having to involve any serverside code like PHP, and in this day and age, people are much keener on this โ€œjust clientsideโ€ or โ€œjust client looking, plus, perhaps, Javascript serverside codeโ€ (ala Node.js) or perhaps โ€œJavascript clientside client code, plus Ajax methodologiesโ€. In any case, it does simplify design to not have to involve a serverside language like PHP โ€ฆ but please donโ€™t think we do not encourage you to learn a serverside language like PHP.

While we are at it here, we continue to think about the mobile device unfriendliness with our current web application, it being, these days, that the setting of the autoplay property for a media object is frowned upon regarding these mobile devices โ€ฆ for reasons of โ€œrunawayโ€ unknown charge issues as you can read at this useful link โ€ฆ thanks โ€ฆ and where they quote from Apple โ€ฆ

โ€œApple has made the decision to disable the automatic playing of video on iOS devices, through both script and attribute implementations.

In Safari, on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and auto-play are disabled. No data is loaded until the user initiates it.โ€ โ€“ Apple documentation.

A link weโ€™d like to thank regarding the new โ€œseekโ€ or media positioning functionality is this one โ€ฆ thanks.

Also, today, for that sense of symmetry, we start to create the Audio objects from now on using โ€ฆ



document.createElement("AUDIO");

โ€ฆ as this acts the same as new Audio() to the best of our testing.

For your own testing purposes, if you know of some media URLs to try, please feel free to try the โ€œoverlayโ€ of media ideas inherent in todayโ€™s splice_audioโšซhtm liveโœ‚run. For todayโ€™s cake โ€œprepared before the programโ€ weโ€™ve again channelled the GoToMeeting Primer Tutorial which had separate audio (albeit very short โ€ฆ sorry โ€ฆ but you get the gist) and video โ€ฆ well, below, you can click on the image to hear the presentation with audio and video synchronized, but only seconds 23 through to 47 of the video should play, and the presentation ending with the image below โ€ฆ

Click to see the audio and video played together synchronously

We think, though, that we will be back regarding this interesting topic, and hope we can improve mobile device functionality.


Previous relevant Spliced Audio/Video/Image Overlay Tutorial is shown below.

Spliced Audio/Video/Image Overlay Tutorial

Spliced Audio/Video/Image Overlay Tutorial

Today weโ€™ve written a second draft of an HTML and Javascript web application that splices up to nine bits of audio or video or image input together, building on the previous Splicing Audio Primer Tutorial as shown below, here, and that can take any of the forms โ€ฆ

  • audio file โ€ฆ and less user friendly is โ€ฆ
  • text that gets turned into speech via Google Translate (and user induced Text to Speech functionality), but needs your button presses
  • video
  • image โ€ฆ and background image for webpage

โ€ฆ for either of the modes of use, that being โ€ฆ

  • discrete โ€ฆ or โ€œOptionalโ€
  • synchronized โ€ฆ or โ€œOverlayโ€

The major new change here, apart from the ability to play two media files at once in our synchronized (or โ€œoverlayedโ€) way, is the additional functionality for Video, and we proceeded thinking thereโ€™d be an Javascript DOM OOPy method like โ€ฆ var xv = new Video(); โ€ฆ to allow for this, but found out from this useful link โ€ฆ thanks โ€ฆ that an alternative approach for Video object creation, on the fly, is โ€ฆ



var xv = document.createElement("VIDEO");

โ€ฆ curiously. And it took us a while to tweak to the idea that to have a โ€œdisplay homeโ€ for the video on the webpage we needed to โ€ฆ



document.body.appendChild(xv);

โ€ฆ which means you need to take care of any HTML form data already filled in, that isnโ€™t that formโ€™s default, when you effectively โ€œrefreshโ€ the webpage like this. Essentially though, media on the fly is a modern approach possible fairly easily with just clientside code. Cute, huh?!

Of course, what we still miss here, is the upload from a local place onto the web server, here at RJM Programming, capability, which we may consider in future, and that some of those other synchronization of media themed blog postings of the past, which you may want to read more, for this type of approach.

In the meantime, if you know of some media URLs to try, please feel free to try the โ€œoverlayโ€ of media ideas inherent in todayโ€™s splice_audioโšซhtm liveโœ‚run. Weโ€™ve thought of this one. Do you remember how the GoToMeeting Primer Tutorial had separate audio (albeit very short โ€ฆ sorry โ€ฆ but you get the gist) and video โ€ฆ well, below, you can click on the image to hear the presentation with audio and video synchronized, and the presentation ending with the image below โ€ฆ

Click to see the audio and video played together synchronously

We think, though, that we will be back regarding this interesting topic.


Previous relevant Splicing Audio Primer Tutorial is shown below.

Spliced Audio Primer Tutorial

Splicing Audio Primer Tutorial

Today weโ€™ve written a first draft of an HTML and Javascript web application that splices up to nine bits of audio input together that can take either of the forms โ€ฆ

  • audio file โ€ฆ and less user friendly is โ€ฆ
  • text that gets turned into speech via Google Translate (and user induced Text to Speech functionality), but needs your button presses

Do you remember, perhaps, when we did a series of blog posts regarding the YouTube API, that finished, so far, with YouTube API Iframe Synchronicity Resizing Tutorial? Well, a lot of what we do today is doing similar sorts of functionalities but just for Audio objects in HTML5. For help on this weโ€™d like to thank this great link. So rather than have HTML audio elements in our HTML, as we first shaped to do, weโ€™ve taken the great advice from this link, and gone all Javascript DOM OOPy on the task, to splice audio media together.

There were three thought patterns going on here for me.

  • The first was a simulation of those Sydney train public announcements where the timbre of the voice differs a bit between when they say โ€œPlatformโ€ and the โ€œ6โ€ (or whatever platform it is) that follows. This is pretty obviously computer audio โ€œbitsโ€ strung together โ€ฆ and wanted to get somewhere towards that capability.
  • The second one relates to presentation ideas following up on that โ€œonmouseoverโ€ Siri audio enhanced presentation we did at Apple iOS Siri Audio Commentary Tutorial. Well, we think we can do something related to that here, and weโ€™ve prepared this cake audio presentation here, for us, in advance โ€ฆ really, thereโ€™s no need for thanks.
  • The third concerns our eternal media file synchronization quests here at this blog that you may find of interest we hope, here.

Also of interest over time has been the Google Translate Text to Speech functionality that used to be very open, and we now only use around here in an interactive โ€œuser clicksโ€ way โ€ฆ but we still use it, because it is very useful, so, thanks. But trying to get this method working for โ€œPlatformโ€ and โ€œ6โ€ without a yawning gap in between ruins the spontaneity and fun somehow, but thereโ€™s nothing stopping you making your own audio files yourself as we did in that Siri tutorial called Apple iOS Siri Audio Commentary Tutorial and take the HTML and Javascript code you could call splice_audioโšซhtml from today, and go and make your own web application? Now, is there? Huh?

Try a liveโœ‚run or perhaps some more Siri cakes?!

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *