Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added volume adjustment. #1

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8270683
Added console log to see which lesson is loading.
computerscientist Aug 18, 2011
c411925
Got rid of console log about lesson being loaded.
computerscientist Aug 18, 2011
d9fdb8f
Moved main script into body of index file.
computerscientist Aug 18, 2011
c7676b8
Tried to put other scripts inside body tags of index file.
computerscientist Aug 18, 2011
d2ceb96
Put last script in body tags.
computerscientist Aug 18, 2011
722f220
Put scripts back in head tags.
computerscientist Aug 18, 2011
1e9ed88
Defined currentLesson variable based on its associated html.
computerscientist Aug 18, 2011
f204d03
Moved main script into body tags.
computerscientist Aug 18, 2011
46e959c
Added console log about current lesson.
computerscientist Aug 19, 2011
0cae110
Added console log about currentLesson variable after it is initialized.
computerscientist Aug 19, 2011
2baa110
Got rid of console log about currentLesson variable.
computerscientist Aug 19, 2011
7ad76d6
Temporarily eliminated current lesson variable while debugging it.
computerscientist Aug 19, 2011
d1e8e7d
Tried to move audio and currentLesson variables into application.js
computerscientist Aug 19, 2011
598da8e
Globalized the app variable in application.js
computerscientist Aug 19, 2011
f8ed386
Tried to add volume control.
computerscientist Aug 19, 2011
3e2943c
Added console log about "a" variable.
computerscientist Aug 19, 2011
160e0f9
Temporarily eliminated volume setting while debugging it.
computerscientist Aug 19, 2011
9a157d9
Eliminated function after audio is initialized while debugging it.
computerscientist Aug 19, 2011
24c4757
Tried to make current lesson variable work.
computerscientist Aug 19, 2011
f48809d
Added console log about current lesson.
computerscientist Aug 19, 2011
e0dd700
Added another console log about current index inner html when it is s…
computerscientist Aug 19, 2011
f463f60
Added console log to tell what lesson is loading.
computerscientist Aug 19, 2011
cb80d20
Experimented with volume setting with sounds.
computerscientist Aug 19, 2011
79689f3
Tried to add property adjustment to sounds (although it doesn't work …
computerscientist Aug 19, 2011
7c91524
Set default speech rate to 200 words per minute.
computerscientist Aug 19, 2011
65324af
Tried to add prefs callback back in.
computerscientist Aug 19, 2011
e376661
Eliminated prefs callback while debugging it.
computerscientist Aug 19, 2011
1b9c0da
Put prefs callback into application.js
computerscientist Aug 19, 2011
ac44976
Temporarily eliminated volume adjustment while debugging it.
computerscientist Aug 19, 2011
13662f7
Added volume adjustment back in.
computerscientist Aug 19, 2011
ddaf5d6
Made sounds play on same audio channel as speech.
computerscientist Aug 19, 2011
4f57b16
Got rid of prefs console log.
computerscientist Aug 19, 2011
510e25b
Tried to add mid-sound volume adjustment.
computerscientist Aug 19, 2011
b900ac8
Fixed reference to audio variable in application.js
computerscientist Aug 19, 2011
69790fc
Tried to move audio into application.js file.
computerscientist Aug 19, 2011
a5574ff
Took audio object out of application.js
computerscientist Aug 19, 2011
0a91bcf
Added prefs callback back in.
computerscientist Aug 19, 2011
1df7d86
Tried to get current lesson to display.
computerscientist Aug 19, 2011
2e675d2
Moved "playingState" variable into index html file javascript.
computerscientist Aug 19, 2011
fcfff38
Tried to initialize audio when page loads, and have game initializati…
computerscientist Aug 19, 2011
4781f4d
Tried to fix some references to audio variable.
computerscientist Aug 19, 2011
6d7181e
Added console log about audio in talk function.
computerscientist Aug 19, 2011
c7663e2
Added console log about audio variable during initialization.
computerscientist Aug 19, 2011
fd84204
Tried to fix audio variable initialization.
computerscientist Aug 19, 2011
82ef618
Moved prefs call into main script in index file.
computerscientist Aug 19, 2011
c4783ab
Added mid-sound volume adjustment.
computerscientist Aug 19, 2011
046d543
Temporarily eliminated mid-sound volume adjustment while debugging it.
computerscientist Aug 19, 2011
d2d34df
Tried to add mid-sound volume adjustment back in for sounds.
computerscientist Aug 19, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions application.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ dojo.require('dojo.hash');
// app when the page loads
dojo.declare('tht.Main', null, {
constructor: function() {
}
});

dojo.ready(function() {
// build our main widget when everything is ready; adjust the name here
// if you change it above but otherwise leave this alone and do all
// work in the widget above
var app = new tht.Main();
});
var app = new tht.Main();
})
77 changes: 53 additions & 24 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@
@import "http://ajax.googleapis.com/ajax/libs/dojo/1.5.0/dijit/themes/claro/claro.css";
@import "css/application.css";
</style>
<script type="text/javascript">
<script type="text/javascript">
var djConfig = {
isDebug: false,
parseOnLoad: true,
baseUrl: './',
modulePaths: {'tht' : 'sounds'}
};
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.5.0/dojo/dojo.xd.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.5.0/dojo/dojo.xd.js"></script>
<script type="text/javascript" src="/libs/uow/trace.js"></script>
<script type="text/javascript" src="/libs/uow.js"></script>
<script type="text/javascript" src="application.js"></script>
<script type="text/javascript" src="bindings.js"></script>
<script type="text/javascript" src="lessons.js"></script>
<script type="text/javascript" src="distance.js"></script>
<script type="text/javascript">
<script type="text/javascript" src="bindings.js"></script>
<script type="text/javascript" src="lessons.js"></script>
<script type="text/javascript" src="distance.js"></script>
<script type="text/javascript">
// Get the audio api controller
var audio = uow.getAudio();
var audio = null;
var currentLesson="";

var playingSound=false;
var masterVolume=1.0;
var speechVolume=1.0;
var soundVolume=1.0;

// Listen for key events
uow.ui.connectKeys();
Expand All @@ -35,18 +41,27 @@
var index;
var sequenceIndex;

//Changes audio preferences whenever game prefs change
function prefsCallback(prefs, which) {
masterVolume=prefs.volume;
speechVolume=prefs.speechVolume;
soundVolume=prefs.soundVolume;

audio.setProperty({name : 'rate', value : prefs.speechRate, immediate : true});
audio.setProperty({name : 'volume', value : prefs.volume*(playingSound ? prefs.soundVolume : prefs.speechVolume), immediate : true});
}

// Pass messages to this function to have them spoken and displayed in the footer
// optional stop parameter preempts the previous speech
function talk(message, stop) {
console.log(message + "\t" + stop);
audio.then(function(a) {
if(stop) {
a.stop();
}
// Slow down the rate to 150 WPM
a.setProperty({name : 'rate', value : 150});
a.say({text : message});
});

if(stop) {
audio.stop();
}

//Set audio properties
audio.say({text : message});

footer = document.getElementById("footer");
footer.innerHTML = message;
Expand All @@ -66,8 +81,14 @@

// Pass urls to this function to have the sound played
function playSound(soundUrl) {
audio.then(function(a) {
a.play({url : soundUrl});
var def=audio.play({url : soundUrl});
def.callBefore(function(){
playingSound=true;
audio.setProperty({name : 'volume', value : masterVolume*soundVolume, immediate : true});
});
def.callAfter(function(){
playingSound=false;
audio.setProperty({name : 'volume', value : masterVolume*speechVolume, immediate : true});
});
}

Expand Down Expand Up @@ -159,7 +180,7 @@
lesson = lessons[lessonName];

currentLesson.innerHTML = lesson.name;

console.log(lesson);
talk(lesson.prompts[index], true);
}

Expand Down Expand Up @@ -199,14 +220,22 @@

dojo.addOnLoad(
function() {
// Pick the lesson or free mode based on the hash part of the url
initialize(dojo.hash());
uow.getAudio().then(function(a){
audio=a;
currentLesson=document.getElementById('currentLesson');

dojo.subscribe('/org/hark/prefs/response', prefsCallback);
dojo.publish('/org/hark/prefs/request');

// Pick the lesson or free mode based on the hash part of the url
initialize(dojo.hash());

// Determine the best size for letter display on load
var letterHeight = document.getElementById('Main').clientHeight * (3/4);
var letterElement = document.getElementById('letterDisplay');
// Determine the best size for letter display on load
var letterHeight = document.getElementById('Main').clientHeight * (3/4);
var letterElement = document.getElementById('letterDisplay');

letterElement.setAttribute('style', 'font-size:' + letterHeight + 'px');
letterElement.setAttribute('style', 'font-size:' + letterHeight + 'px');
});
}
);
</script>
Expand Down