forked from Eddy34743/Corona-Comics-SDK-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsound.lua
319 lines (305 loc) · 19.4 KB
/
sound.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
--
-- Abstract: Corona Comics 2 Demo
-- Be Confident in Who You Are: A Middle School Confidential™ Graphic Novel Lite Version
--
-- Version: 2.0 (September 20, 2011)
-- Sample code is MIT licensed, see http://developer.anscamobile.com/code/license
-- Copyright (C) 2011 Electric Eggplant. All Rights Reserved.
-- Copyright (C) 2011 ANSCA Inc. All Rights Reserved.
--
-- Images and text excerpted from "Be Confident in Who You Are" by Annie Fox, M.Ed.,
-- (C) 2008. Used with permission of Free Spirit Publishing Inc., Minneapolis,
-- MN; 800-735-7323; www.freespirit.com. All Rights Reserved.
--
-- balloons.lua - coordinate and size information for all the text balloons.
--
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
--
-- First 14 channels are reserved for music, ambient and other looping sounds:
--
-- channel 1-2 -- music channels
-- channel 3-6 -- ambient (e.g., outdoor background sound)
-- channel 7-14 -- looping sounds
-- channels 15-32 -- open channels for UI, repeating sounds, or quick sounds
--
-- We could change the allocation, but be sure to also change the
-- audio.reserveChannels( 14 )
-- line in main.lua
--
-- Notes:
-- Each page can have sounds defined for both zoomed-out mode, as well as sounds
-- for each frame/camera-move. If nothing is defined for a specific frame, it uses
-- the sounds defined for the full page.
--
-- Be sure to fade out looping sounds when you move to a page or frame where you no
-- longer wish to hear it. For example, if there's a sound played in a specific
-- frame but it shouldn't play for the full page, then the full page definition
-- should include a fade out of that sound, as should adjacent frames, and adjacent
-- pages (if this is the first or last frame on a page).
-- --
-- Make sure you're not using the same channel for two different sounds at the same
-- time. Best practice would be to not use the same channel in adjacent
-- pages/frames so sounds don't step on each other. This is especially important if
-- you want cross fading between two sounds.
--
--
-- Parameters that can be included in the table:
-- channel - which channel to play the sound on
-- sound - the handle of the loaded sound, e.g., sndAmbOutdoors
-- start_volume - volume the sound should start at
-- targ_volume - the volume we want the sound to end up at, values of 0-1
-- fade_duration - how long should it take for the sound to reach its targ_volume (in miliseconds)
-- loop - number of times to loop, or -1 if it loops continuously
--
-- Additional notes - 9/20/11
-- In the full version of the app we're using audio.loadSound for many of the
-- sounds to speed up the initial load (especially for iPhone and NOOK Color.
-- Recent changes to Corona (after build 605) seem to cause problems here because
-- we're loading too many streams, resulting in "WARNING: Failed to create audio
-- sound()". In this demo version, we were getting an "59Testing error: Invalid
-- Operation" for an unknown reason.
--
-- If this isn't fixed in a future build then we may have to load sounds by chapter
-- rather than all at the beginning.
--
local sndDir = "sound/"
local sndExt = ".m4a"
if _G.device == "android" then
sndExt = ".mp3"
end
------------------------------------------------------------
-- Reserved sound channel allocation
------------------------------------------------------------
local musicCh1 = 1
local musicCh2 = 2
local ambCh1 = 3
local ambCh2 = 4
local ambCh3 = 5
local ambCh4 = 6
local loopCh1 = 7
local loopCh2 = 8
local loopCh3 = 9
local loopCh4 = 10
local loopCh5 = 11
local loopCh6 = 12
local loopCh7 = 13
local loopCh8 = 14
------------------------------------------------------------
-- Load the sounds
------------------------------------------------------------
-- UI sounds, needed throughout the app
sndUIBeep1 = audio.loadSound( sndDir .. "ui_beep_1" .. sndExt )
sndUIClick1 = audio.loadSound( sndDir .. "ui_click_1" .. sndExt )
sndUIClick2 = audio.loadSound( sndDir .. "ui_click_2" .. sndExt )
sndUIPageTurn = audio.loadSound( sndDir .. "ui_page_turn_1" .. sndExt )
sndUIZoom1In = audio.loadSound( sndDir .. "zoom1_in" .. sndExt )
sndUIZoom1Out = audio.loadSound( sndDir .. "zoom1_out" .. sndExt )
-- Chapter-related sounds. Some of these may work better as loadStream
local musicMainTheme = audio.loadSound( sndDir .. "msc_theme" .. sndExt )
local sndAbbyCryFlashback = audio.loadSound( sndDir .. "abby_cry_flashback" .. sndExt )
local sndAmbHouseIndoor = audio.loadSound( sndDir .. "amb_house_indoor_lp" .. sndExt )
local sndAmbOutdoors = audio.loadSound( sndDir .. "amb_outdoor_lp" .. sndExt )
local sndAmbPoolFlashback = audio.loadSound( sndDir .. "amb_pool_flashback_lp" .. sndExt )
local sndAmbSuburbs = audio.loadSound( sndDir .. "amb_suburbs_short" .. sndExt )
local sndBasketballDribble = audio.loadSound( sndDir .. "basketball_dribble_01" .. sndExt )
local sndBasketballNet = audio.loadSound( sndDir .. "basketball_net" .. sndExt )
local sndBasketballShoot = audio.loadSound( sndDir .. "basketball_shoot_01" .. sndExt )
local sndBasketballShootDribble = audio.loadSound( sndDir .. "basketball_shoot_02" .. sndExt )
local sndBlender = audio.loadSound( sndDir .. "blender" .. sndExt )
local sndCheerGroup = audio.loadSound( sndDir .. "cheer_group" .. sndExt )
local sndCrowdMurmurSmall = audio.loadSound( sndDir .. "crowd_murmur_small_lp" .. sndExt )
local sndIceInGlass = audio.loadSound( sndDir .. "ice_in_glass_01" .. sndExt )
local sndLoopClappingFriends = audio.loadSound( sndDir .. "clapping_friends" .. sndExt )
local sndLoopPushup = audio.loadSound( sndDir .. "pushup" .. sndExt )
local sndMateoGrowl = audio.loadSound( sndDir .. "Mateo_growl_1" .. sndExt )
local sndMichelleLaugh = audio.loadSound( sndDir .. "michelle_laugh" .. sndExt )
------------------------------------------------------------
-- Sound table
------------------------------------------------------------
local sound =
{
[0] = {
{ {delay = 1000, channel = musicCh1, sound = musicMainTheme, start_volume = 1, loop = -1} }, -- for full page mode
},
[1] = {
{ {channel = musicCh1, sound = musicMainTheme, start_volume = 0, targ_volume = 1, fade_duration = 2000, loop = -1}, -- for full page
{channel = ambCh1, targ_volume = 0, fade_duration = 2000 }, -- fade out sndAmbSuburbs from page 2 (if we return to page 1)
{channel = loopCh3, targ_volume = 0, fade_duration = 1000} }, -- fade out sndLoopClappingFriends from page 2 (if we return to page 1)
},
[2] = {
{ {channel = musicCh1, targ_volume = 0, fade_duration = 2000}, -- for full page, fade out musicMainTheme from page 1
{channel = loopCh3, sound = sndLoopClappingFriends, start_volume = 0, targ_volume = 1, fade_duration = 1000, loop = -1},
{channel = loopCh4, targ_volume = 0, fade_duration = 500}, -- sndCrowdMurmurSmall
{channel = loopCh6, targ_volume = 0, fade_duration = 500}, -- sndCheerGroup
{channel = ambCh1, sound = sndAmbSuburbs, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1} },
{ {channel = musicCh1, targ_volume = 0, fade_duration = 2000}, -- frame 1, fade-out musicMainTheme from page 1
{channel = loopCh3, sound = sndLoopClappingFriends, start_volume = 0, targ_volume = 1, fade_duration = 1000, loop = -1},
{channel = ambCh1, sound = sndAmbSuburbs, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1} },
{ {channel = loopCh3, sound = sndLoopClappingFriends, start_volume = 0, targ_volume = 1, fade_duration = 1000, loop = -1}, -- frame 2
{channel = loopCh6, targ_volume = 0, fade_duration = 500}, -- sndCheerGroup
{channel = ambCh1, sound = sndAmbSuburbs, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1} },
{ {channel = loopCh3, sound = sndLoopClappingFriends, start_volume = 0, targ_volume = 1, fade_duration = 1000, loop = -1}, -- frame 3
{delay = 950, channel = loopCh6, sound = sndCheerGroup, start_volume = .7 },
{channel = ambCh1, sound = sndAmbSuburbs, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1},
{channel = loopCh4, targ_volume = 0, fade_duration = 500}, -- sndCrowdMurmurSmall
},
{ {channel = ambCh1, sound = sndAmbSuburbs, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 4
{channel = loopCh6, targ_volume = 0, fade_duration = 1000}, -- sndCheerGroup
{channel = loopCh3, targ_volume = 0, fade_duration = 2000}, -- sndLoopClappingFriends
{channel = loopCh4, sound = sndCrowdMurmurSmall, start_volume = 0, targ_volume = .6, fade_duration = 1000, loop = -1},
{channel = loopCh5, targ_volume = 0, fade_duration = 500}, -- sndMateoGrowl
},
{ {channel = ambCh1, sound = sndAmbSuburbs, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 5
{channel = loopCh3, targ_volume = 0, fade_duration = 2000}, -- sndLoopClappingFriends
{channel = loopCh4, sound = sndCrowdMurmurSmall, start_volume = 0, targ_volume = .6, fade_duration = 1000, loop = -1},
{delay = 350, channel = loopCh5, sound = sndMateoGrowl, start_volume = .5},
},
},
[3] = {
{ {channel = ambCh1, sound = sndAmbSuburbs, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- for full page
{channel = ambCh2, targ_volume = 0, fade_duration = 2000}, -- sndAmbOutdoors
{channel = loopCh1, targ_volume = 0, fade_duration = 2000}, -- sndBasketballShootDribble
{channel = loopCh2, targ_volume = 0, fade_duration = 2000}, -- sndBasketballDribble
{channel = loopCh3, targ_volume = 0, fade_duration = 1000}, -- sndLoopClappingFriends
{channel = loopCh4, targ_volume = 0, fade_duration = 500}, -- sndCrowdMurmurSmall
{channel = loopCh5, targ_volume = 0, fade_duration = 500}, -- sndMateoGrowl
},
},
[4] = { -- chapter 1
{ {channel = ambCh1, targ_volume = 0, fade_duration = 2000}, -- for full page, sndAmbSuburbs,
{channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1},
{channel = loopCh2, targ_volume = 0}, -- remove sndBasketballDribble before restarting it
{delay = 700, channel = loopCh1, sound = sndBasketballShootDribble, start_volume = 1},
{delay = 2700, channel = loopCh2, sound = sndBasketballDribble, start_volume = 1, loop = -1} },
{ {channel = ambCh1, targ_volume = 0, fade_duration = 2000}, -- frame 1, sndAmbSuburbs
{channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1},
{channel = loopCh2, start_volume = 0}, -- remove sndBasketballDribble before restarting it
{delay = 700, channel = loopCh1, sound = sndBasketballShootDribble, start_volume = 1},
{delay = 2700, channel = loopCh2, sound = sndBasketballDribble, start_volume = 1, loop = -1} },
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 1000, loop = -1}, -- frame 2
{channel = loopCh2, start_volume = 0}, -- remove sndBasketballDribble before restarting it
{delay = 500, channel = loopCh2, sound = sndBasketballDribble, start_volume = 1, loop = -1} },
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 1000, loop = -1}, -- frame 3
{channel = loopCh2, start_volume = 0}, -- remove sndBasketballDribble before restarting it
{delay = 500, channel = loopCh2, sound = sndBasketballDribble, start_volume = 1, loop = -1} },
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 1000, loop = -1}, -- frame 4
{channel = loopCh2, start_volume = 0}, -- remove sndBasketballDribble before restarting it
{delay = 500, channel = loopCh2, sound = sndBasketballDribble, start_volume = 1, loop = -1} },
},
[5] = {
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- for full page
{channel = ambCh1, targ_volume = 0, fade_duration = 1000}, -- sndAmbPoolFlashback
{channel = loopCh2, targ_volume = 0}, -- remove sndBasketballDribble before restarting it
{delay = 700, channel = loopCh2, sound = sndBasketballDribble, start_volume = 1, loop = -1} },
{ {delay = 700, sound = sndBasketballShoot, start_volume = 1 }, -- frame 1
{channel = loopCh2, start_volume = 0}, -- remove sndBasketballDribble before restarting it
{delay = 1700, channel = loopCh2, sound = sndBasketballDribble, start_volume = 1, loop = -1} },
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 2
{channel = loopCh2, start_volume = 0}, -- remove sndBasketballDribble
{delay = 700, channel = loopCh2, sound = sndBasketballShootDribble, start_volume = 1},
{delay = 3700, sound = sndBasketballNet, start_volume = 1 },
{delay = 5900, channel = loopCh2, sound = sndBasketballDribble, start_volume = 1, loop = -1} },
{ }, -- frame 3
{ }, -- frame 4
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 5
{channel = ambCh1, targ_volume = 0, fade_duration = 1000}, -- sndAmbPoolFlashback
{channel = loopCh2, start_volume = 0}, -- remove sndBasketballDribble
{delay = 700, sound = sndBasketballNet, start_volume = 1 },
{delay = 2900, channel = loopCh2, sound = sndBasketballDribble, start_volume = 1, loop = -1} },
},
[6] = {
{ {channel = ambCh2, targ_volume = 0, fade_duration = 2000}, -- for full page, fade-out sndAmbOutdoors
{channel = ambCh1, sound = sndAmbPoolFlashback, start_volume = 0, targ_volume = .5, fade_duration = 2000, loop = -1},
{channel = loopCh2, start_volume = 0} }, -- remove sndBasketballDribble
{ {channel = ambCh2, targ_volume = 0, fade_duration = 2000}, -- frame 1, remove sndAmbOutdoors
{channel = loopCh2, start_volume = 0}, -- remove sndBasketballDribble
{channel = ambCh1, sound = sndAmbPoolFlashback, start_volume = 0, targ_volume = .1, fade_duration = 2000, loop = -1} },
{ {channel = ambCh1, sound = sndAmbPoolFlashback, targ_volume = .3, fade_duration = 2000, loop = -1} }, -- frame 2
{ {channel = ambCh1, sound = sndAmbPoolFlashback, targ_volume = .3, fade_duration = 1000, loop = -1}, -- frame 3
{delay=500, sound = sndIceInGlass, start_volume = 1},
{delay=1000, sound = sndIceInGlass, start_volume = 1},
{delay=2500, sound = sndIceInGlass, start_volume = 1},
{delay=4500, sound = sndIceInGlass, start_volume = 1},
{delay=7500, sound = sndIceInGlass, start_volume = 1},
{delay=8200, sound = sndIceInGlass, start_volume = 1},
{delay=8900, sound = sndIceInGlass, start_volume = 1},
{channel = loopCh2, targ_volume = 0, fade_duration = 1000}, -- sndAbbyCryFlashback
},
{ {channel = ambCh1, sound = sndAmbPoolFlashback, targ_volume = .3, fade_duration = 1000, loop = -1}, -- frame 4
{delay = 750, channel = loopCh2, sound = sndAbbyCryFlashback, start_volume = 1} },
{ {channel = ambCh2, targ_volume = 0, fade_duration = 2000}, -- frame 5, sndAmbOutdoors
{channel = loopCh2, targ_volume = 0, fade_duration = 1000}, -- sndAbbyCryFlashback
{channel = ambCh1, sound = sndAmbPoolFlashback, targ_volume = .1, fade_duration = 2000, loop = -1} }
},
[7] = {
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- for full page
{channel = loopCh2, targ_volume = 0, fade_duration = 1000}, -- sndMichelleLaugh
{channel = ambCh1, targ_volume = 0, fade_duration = 700}, -- sndAmbPoolFlashback
},
{ }, -- frame 1
{ }, -- frame 2
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 3
{channel = loopCh2, targ_volume = 0, fade_duration = 1000}, -- sndMichelleLaugh
},
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 4
{delay = 350, channel = loopCh2, sound = sndMichelleLaugh, start_volume = 1} },
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 5
{channel = loopCh2, targ_volume = 0, fade_duration = 1000}, -- sndMichelleLaugh
{channel = loopCh1, targ_volume = 0, fade_duration = 1000}, -- sndLoopPushup
},
{ }, -- frame 6
{ }, -- frame 7
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 8
{channel = loopCh1, targ_volume = 0, fade_duration = 1000},}, -- sndLoopPushup
},
[8] = {
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- for full page
{channel = ambCh1, targ_volume = 0, fade_duration = 1000}, -- sndAmbHouseIndoor
{channel = loopCh1, targ_volume = 0, fade_duration = 1000}, -- sndLoopPushup
{channel = loopCh2, targ_volume = 0, fade_duration = 1000}, -- sndBlender
{channel = musicCh1, targ_volume = 0, fade_duration = 2000} }, -- musicMainTheme
{ {channel = ambCh2, targ_volume = 0, fade_duration = 1000}, -- frame 1, sndAmbOutdoors
{channel = ambCh1, sound = sndAmbHouseIndoor, targ_volume = .3, fade_duration = 2000, loop = -1},
{delay = 700, channel = loopCh1, sound = sndLoopPushup, start_volume = .7, loop = 4},
{channel = loopCh2, targ_volume = 0, fade_duration = 1000} }, -- sndBlender
{ {channel = loopCh1, targ_volume = 0, fade_duration = 1000}, -- frame 2, sndLoopPushup
{channel = ambCh1, sound = sndAmbHouseIndoor, targ_volume = .3, fade_duration = 2000, loop = -1},
{channel = loopCh2, sound = sndBlender, start_volume = 1} },
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 3
{channel = ambCh1, targ_volume = 0, fade_duration = 1000}, -- sndAmbHouseIndoor
{channel = loopCh2, targ_volume = 0, fade_duration = 1000} }, -- sndBlender
{ {channel = ambCh2, sound = sndAmbOutdoors, start_volume = 0, targ_volume = .3, fade_duration = 2000, loop = -1}, -- frame 4
{channel = musicCh1, targ_volume = 0, fade_duration = 2000}, -- musicMainTheme
{channel = ambCh1, targ_volume = 0, fade_duration = 1000}, -- sndAmbHouseIndoor
},
},
[9] = {
{ {channel = ambCh2, targ_volume = 0, fade_duration = 2000}, -- for full page, sndAmbOutdoors
{channel = musicCh1, sound = musicMainTheme, start_volume = 0, targ_volume = 1, fade_duration = 2000, loop = -1},
{channel = ambCh1, targ_volume = 0, fade_duration = 1000}, -- sndAmbHouseIndoor
},
},
[10] = {
{ {channel = musicCh1, sound = musicMainTheme, start_volume = 0, targ_volume = 1, fade_duration = 2000, loop = -1}, -- for full page
},
},
[11] = {
{{channel = musicCh1, targ_volume = 0, fade_duration = 2000} } -- for full page, musicMainTheme
},
[12] = {
},
[13] = {
},
[14] = {
},
[15] = {
},
[16] = {
},
[17] = {
},
}
return sound