2
* Copyright (C) 2012, 2013 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
readonly property int totalSpots: 30
24
readonly property int totalIdles: 7
26
property real __newPeak: 0
30
desiredInterval: peakMover.interval
42
voiceAmplitudes.itemAt(0).amplitude = __newPeak
47
id: fixedPositionSoundAmplitudes
49
delegate: SoundAmplitudeDelegate {
50
totalCount: fixedPositionSoundAmplitudes.count
60
delegate: SoundAmplitudeDelegate {
61
totalCount: voiceAmplitudes.count
69
delegate: SoundAmplitudeDelegate {
70
totalCount: idleAmplitudes.count
73
visible: idleAmplitudes.enabled
77
function setDetectorEnabled(enabled) {
78
idleAmplitudes.enabled = false
82
peakDetector.enabled = false
87
function moveBalls() {
89
var amplitude = voiceAmplitudes.itemAt(0).amplitude
90
for (var i = 1; i < totalSpots; ++i) {
91
var item = voiceAmplitudes.itemAt(i)
92
var tempAmplitude = item.amplitude
93
item.amplitude = amplitude
94
amplitude = tempAmplitude
98
property int __firstIdle
99
property int __idleCount
104
onTriggered: moveAndAddIdleBalls()
107
function moveAndAddIdleBalls() {
108
// Check if we are doing the real thing
109
if (!idleAmplitudes.enabled) {
113
for (var i = 0; i < __idleCount; ++i) {
114
var index = __firstIdle - i
115
var item = idleAmplitudes.itemAt(index % totalSpots)
116
var nextItem = idleAmplitudes.itemAt((index + 1) % totalSpots)
117
nextItem.opacity = item.opacity
120
idleAmplitudes.itemAt((__firstIdle - __idleCount) % totalSpots).opacity = 0
122
if (__idleCount < totalIdles) {
123
idleAmplitudes.itemAt(0).opacity = 1 - (__idleCount / totalIdles)
126
idleBallsTimer.start()
129
function startIdle() {
130
// On the device the peak detector takes quite a lot to start up
131
// so enable it as soon as we know we are going to do voice capture
132
peakDetector.enabled = true
133
for (var i = 0; i < totalSpots; ++i) {
134
idleAmplitudes.itemAt(i).opacity = 0
136
for (var i = 0; i < totalSpots; ++i) {
137
voiceAmplitudes.itemAt(i).amplitude = 0
140
idleAmplitudes.enabled = true
141
idleAmplitudes.itemAt(0).opacity = 1
144
idleBallsTimer.start()