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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>audio_mixer_user.cpp</h1><a href="audio__mixer__user_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025
00026 <font class="preprocessor">#include "<a class="code" href="stdsound_8h.html">stdsound.h</a>"</font>
00027
00028 <font class="comment">//#include "env_sound_user.h"</font>
00029 <font class="comment">//#include "env_effect.h"</font>
00030 <font class="preprocessor">#include "<a class="code" href="simple__sound_8h.html">simple_sound.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="complex__sound_8h.html">complex_sound.h</a>"</font>
00032 <font class="comment">//#include "ambiant_source.h"</font>
00033 <font class="comment">//#include "bounding_sphere.h"</font>
00034 <font class="comment">//#include "bounding_box.h"</font>
00035 <font class="preprocessor">#include "<a class="code" href="buffer_8h.html">driver/buffer.h</a>"</font>
00036 <font class="preprocessor">#include "<a class="code" href="sample__bank_8h.html">sample_bank.h</a>"</font>
00037 <font class="preprocessor">#include "<a class="code" href="sound__bank_8h.html">sound_bank.h</a>"</font>
00038 <font class="preprocessor">#include "<a class="code" href="background__sound__manager_8h.html">background_sound_manager.h</a>"</font>
00039 <font class="preprocessor">#include "<a class="code" href="simple__source_8h.html">simple_source.h</a>"</font>
00040 <font class="preprocessor">#include "<a class="code" href="complex__source_8h.html">complex_source.h</a>"</font>
00041 <font class="preprocessor">#include "<a class="code" href="background__source_8h.html">background_source.h</a>"</font>
00042
00043
00044 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font>
00045 <font class="preprocessor">#include "<a class="code" href="path_8h.html">nel/misc/path.h</a>"</font>
00046 <font class="preprocessor">#include "<a class="code" href="time__nl_8h.html">nel/misc/time_nl.h</a>"</font>
00047 <font class="preprocessor">#include "<a class="code" href="command_8h.html">nel/misc/command.h</a>"</font>
00048
00049 <font class="preprocessor">#include "<a class="code" href="context__sound_8h.html">context_sound.h</a>"</font>
00050 <font class="preprocessor">#include <iomanip.h></font>
00051
00052 <font class="comment">//#include <crtdbg.h></font>
00053
00054 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00055
00056 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00057
00058
00059 <font class="keyword">namespace </font>NLSOUND {
00060
00061
00062 <font class="preprocessor">#ifdef _DEBUG</font>
00063 <font class="preprocessor"></font>CAudioMixerUser::IMixerEvent *CurrentEvent = 0;
00064 <font class="preprocessor">#endif</font>
00065 <font class="preprocessor"></font>
00066
<a name="l00067"></a><a class="code" href="audio__mixer__user_8cpp.html#a0">00067</a> <font class="preprocessor">#define NL_TRACE_MIXER 0</font>
00068 <font class="preprocessor"></font>
00069 <font class="preprocessor">#if NL_TRACE_MIXER</font>
00070 <font class="preprocessor"></font><font class="preprocessor">#define _profile(_a) nldebug ## _a</font>
00071 <font class="preprocessor"></font><font class="preprocessor">#else</font>
<a name="l00072"></a><a class="code" href="audio__mixer__user_8cpp.html#a1">00072</a> <font class="preprocessor"></font><font class="preprocessor">#define _profile(_a) </font>
00073 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00074 <font class="preprocessor"></font>
00075 <font class="comment">// The audio mixer singleton instance</font>
<a name="l00076"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">00076</a> CAudioMixerUser *CAudioMixerUser::_Instance = NULL;
00077
00078 <font class="comment">// Return the priority cstring (debug info)</font>
00079 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNLSOUND.html#a15">PriToCStr</a> [<a class="code" href="namespaceNLSOUND.html#a82a14">NbSoundPriorities</a>] = { <font class="stringliteral">"XH"</font>, <font class="stringliteral">"HI"</font>, <font class="stringliteral">"MD"</font>, <font class="stringliteral">"LO"</font> };
00080
00081
00082 <font class="comment">// ******************************************************************</font>
00083
00084 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNLSOUND.html#a75">getPriorityStr</a>( <a class="code" href="namespaceNLSOUND.html#a82">TSoundPriority</a> p )
00085 {
00086 <a class="code" href="debug_8h.html#a6">nlassert</a>( ((uint)p) < <a class="code" href="namespaceNLSOUND.html#a82a14">NbSoundPriorities</a> );
00087 <font class="keywordflow">return</font> <a class="code" href="namespaceNLSOUND.html#a15">PriToCStr</a>[p];
00088 }
00089
00090
00091 <font class="comment">// ******************************************************************</font>
00092
<a name="l00093"></a><a class="code" href="classNLSOUND_1_1UAudioMixer.html#d0">00093</a> UAudioMixer *UAudioMixer::createAudioMixer()
00094 {
00095 <font class="keywordflow">return</font> <font class="keyword">new</font> CAudioMixerUser();
00096 }
00097
00098
00099 <font class="comment">// ******************************************************************</font>
00100
<a name="l00101"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a0">00101</a> CAudioMixerUser::CAudioMixerUser() : _SoundDriver(NULL),
00102 _ListenPosition(CVector::Null),
00103 <font class="comment">// _EnvSounds(NULL),</font>
00104 <font class="comment">// _BalancePeriod(0),</font>
00105 _CurEnvEffect(NULL),
00106 _NbTracks(0),
00107 _MaxNbTracks(0),
00108 _Leaving(false),
00109 _BackgroundSoundManager(0),
00110 _PlayingSources(0)
00111 {
00112 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">_Instance</a> == NULL )
00113 {
00114 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">_Instance</a> = <font class="keyword">this</font>;
00115
00116 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
00117 <font class="preprocessor"></font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m7">_UpdateTime</a> = 0.0;
00118 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m8">_CreateTime</a> = 0.0;
00119 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m9">_UpdateCount</a> = 0;
00120 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m10">_CreateCount</a> = 0;
00121 <font class="preprocessor">#endif</font>
00122 <font class="preprocessor"></font>
00123 }
00124 <font class="keywordflow">else</font>
00125 {
00126 <a class="code" href="debug_8h.html#a3">nlerror</a>( <font class="stringliteral">"Audio mixer singleton instanciated twice"</font> );
00127 }
00128 }
00129
00130
00131 <font class="comment">// ******************************************************************</font>
00132
<a name="l00133"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a1">00133</a> CAudioMixerUser::~CAudioMixerUser()
00134 {
00135 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"AM: Releasing..."</font> );
00136
00137 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a> != 0)
00138 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>;
00139 <font class="comment">// CBackgroundSoundManager::release();</font>
00140
00141 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a5">reset</a>();
00142
00143 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m5">_Leaving</a> = <font class="keyword">true</font>;
00144
00145 <font class="comment">// Release the sound bank</font>
00146 CSoundBank::release();
00147 <font class="comment">// Release all the SampleBanks</font>
00148 CSampleBank::releaseAll();
00149
00150 <font class="comment">// Tracks</font>
00151 uint i;
00152 <font class="keywordflow">for</font> ( i=0; i!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; i++ )
00153 {
00154 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i] )
00155 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i];
00156 }
00157
00158 <font class="comment">// Sound driver</font>
00159 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a> != NULL )
00160 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>;
00161
00162 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">_Instance</a> = NULL;
00163
00164 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"AM: Released"</font> );
00165 }
00166
00167
<a name="l00168"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a3">00168</a> <font class="keywordtype">void</font> CAudioMixerUser::setPriorityReserve(<a class="code" href="namespaceNLSOUND.html#a82">TSoundPriority</a> priorityChannel, uint reserve)
00169 {
00170 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o2">_PriorityReserve</a>[priorityChannel] = <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>, reserve);
00171 }
00172
<a name="l00173"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a4">00173</a> <font class="keywordtype">void</font> CAudioMixerUser::setLowWaterMark(uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
00174 {
00175 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o4">_LowWaterMark</a> = <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>);
00176 }
00177
00178
00179 <font class="comment">// ******************************************************************</font>
00180
<a name="l00181"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a30">00181</a> <font class="keywordtype">void</font> CAudioMixerUser::writeProfile(std::ostream& out)
00182 {
00183 <font class="comment">// compute number of muted source</font>
00184 uint nb = 0;
00185
00186 <font class="comment">/* TSourceContainer::iterator first(_Sources.begin()), last(_Sources.end());</font>
00187 <font class="comment"> for (; first != last; ++first)</font>
00188 <font class="comment"> {</font>
00189 <font class="comment"> CSimpleSource *psu = *first;</font>
00190 <font class="comment"> if (psu->getTrack() == NULL)</font>
00191 <font class="comment"> {</font>
00192 <font class="comment"> ++nb;</font>
00193 <font class="comment"> }</font>
00194 <font class="comment"> }</font>
00195 <font class="comment">*/</font>
00196 <font class="comment">/* hash_set<CSimpleSource*>::const_iterator ips;</font>
00197 <font class="comment"> for ( ips=_Sources.begin(); ips!=_Sources.end(); ++ips )</font>
00198 <font class="comment"> {</font>
00199 <font class="comment"> CSimpleSource *psu = *ips;</font>
00200 <font class="comment"> if (psu->getTrack() == NULL)</font>
00201 <font class="comment"> {</font>
00202 <font class="comment"> ++nb;</font>
00203 <font class="comment"> }</font>
00204 <font class="comment"> }</font>
00205 <font class="comment">*/</font>
00206 out << <font class="stringliteral">"Mixer: \n"</font>;
00207 out << <font class="stringliteral">"Playing sources: "</font> << <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a23">getPlayingSourcesNumber</a>() << <font class="stringliteral">" \n"</font>;
00208 out << <font class="stringliteral">"Available tracks: "</font> << <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a24">getNumberAvailableTracks</a>() << <font class="stringliteral">" \n"</font>;
00209 <font class="comment">// out << "Muted sources: " << nb << " \n";</font>
00210 <font class="comment">// out << "Muted sources: " << max(0, sint(_PlayingSources.size())-sint(_NbTracks)) << " \n";</font>
00211 out << <font class="stringliteral">"Muted sources: "</font> << max(0, <a class="code" href="memory__common_8h.html#a14">sint</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m1">_PlayingSources</a>)-<a class="code" href="memory__common_8h.html#a14">sint</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>)) << <font class="stringliteral">" \n"</font>;
00212 out << <font class="stringliteral">"Sources waiting for play: "</font> << <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.size() << <font class="stringliteral">" \n"</font>;
00213 out << <font class="stringliteral">"HighestPri: "</font> << <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[<a class="code" href="namespaceNLSOUND.html#a82a10">HighestPri</a>] << <font class="stringliteral">" \n"</font>;
00214 out << <font class="stringliteral">"HighPri: "</font> << <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[<a class="code" href="namespaceNLSOUND.html#a82a11">HighPri</a>] << <font class="stringliteral">" \n"</font>;
00215 out << <font class="stringliteral">"MidPri: "</font> << <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[<a class="code" href="namespaceNLSOUND.html#a82a12">MidPri</a>] << <font class="stringliteral">" \n"</font>;
00216 out << <font class="stringliteral">"LowPri: "</font> << <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[<a class="code" href="namespaceNLSOUND.html#a82a13">LowPri</a>] << <font class="stringliteral">" \n"</font>;
00217 out << <font class="stringliteral">"Average update time: "</font> << std::setw(10) << (1000.0 * <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m7">_UpdateTime</a> / <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m9">_UpdateCount</a>) << <font class="stringliteral">" msec\n"</font>;
00218 out << <font class="stringliteral">"Average create time: "</font> << std::setw(10) <<(1000.0 * <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m8">_CreateTime</a> / <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m10">_CreateCount</a>) << <font class="stringliteral">" msec\n"</font>;
00219 out << <font class="stringliteral">"Estimated CPU: "</font> << std::setiosflags(ios::right) << std::setprecision(6) << std::setw(10) << (100.0 * 1000.0 * (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m7">_UpdateTime</a> + <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m8">_CreateTime</a>) / <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a51">curTime</a>()) << <font class="stringliteral">"%\n"</font>;
00220
00221 <font class="keywordflow">if</font> (_SoundDriver)
00222 {
00223 out << <font class="stringliteral">"\n"</font>;
00224 out << <font class="stringliteral">"Driver: \n"</font>;
00225 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>->writeProfile(out);
00226 }
00227 }
00228
00229 <font class="comment">// ******************************************************************</font>
00230
<a name="l00231"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a50">00231</a> <font class="keywordtype">void</font> CAudioMixerUser::addSourceWaitingForPlay(CSimpleSource *source)
00232 {
00233 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.push_back(source);
00234 }
00235
00236
00237 <font class="comment">// ******************************************************************</font>
00238
<a name="l00239"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a5">00239</a> <font class="keywordtype">void</font> CAudioMixerUser::reset()
00240 {
00241 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m5">_Leaving</a> = <font class="keyword">true</font>;
00242
00243 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.clear();
00244
00245 <font class="comment">// Stop tracks</font>
00246 uint i;
00247 <font class="keywordflow">for</font> ( i=0; i!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; i++ )
00248 {
00249 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i] )
00250 {
00251 CSimpleSource* <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]->getSource();
00252
00253 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> && <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>->isPlaying())
00254 {
00255 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>->stop();
00256 }
00257 }
00258 }
00259
00260 <font class="comment">// Sources</font>
00261 <font class="keywordflow">while</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.empty())
00262 {
00263 <font class="comment">//removeSource( _Sources.begin(), true ); // 3D sources, the envsounds were removed above</font>
00264 CSourceCommon *source = *(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.begin());
00265 <font class="keywordflow">if</font> (source->isPlaying())
00266 source->stop();
00267 <font class="keywordflow">else</font>
00268 <font class="keyword">delete</font> source;
00269 }
00270
00271 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m5">_Leaving</a> = <font class="keyword">false</font>;
00272 }
00273
00274 <font class="comment">// ******************************************************************</font>
00275
<a name="l00276"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a2">00276</a> <font class="keywordtype">void</font> CAudioMixerUser::init( <font class="comment">/*uint32 balance_period */</font>)
00277 {
00278 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"AM: Init..."</font> );
00279
00280 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: ---------------------------------------------------------------"</font> ));
00281 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: DRIVER: %s"</font>, NLSOUND_DLL_NAME ));
00282
00283 <font class="comment">// Init sound driver</font>
00284 <font class="keywordflow">try</font>
00285 {
00286 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a> = ISoundDriver::createDriver();
00287 }
00288 <font class="keywordflow">catch</font>(...)
00289 {
00290 <font class="keyword">delete</font> <font class="keyword">this</font>;
00291 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#r0">_Instance</a> = NULL;
00292 <font class="keywordflow">throw</font>;
00293 }
00294
00295 uint i;
00296
00297
00298 <font class="comment">// Init registrable classes</font>
00299 <font class="keyword">static</font> <font class="keywordtype">bool</font> initialized = <font class="keyword">false</font>;
00300 <font class="keywordflow">if</font> (!initialized)
00301 {
00302 <font class="comment">// CSimpleSource::init();</font>
00303 initialized = <font class="keyword">true</font>;
00304 }
00305
00306 <font class="comment">// Init listener</font>
00307 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o7">_Listener</a>.init( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a> );
00308
00309 <font class="comment">// Init tracks (physical sources)</font>
00310 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a> = <a class="code" href="namespaceNLSOUND.html#a16">MAX_TRACKS</a>; <font class="comment">// could be chosen by the user, or according to the capabilities of the sound card</font>
00311 <font class="keywordflow">for</font> ( i=0; i<<a class="code" href="namespaceNLSOUND.html#a16">MAX_TRACKS</a>; i++ )
00312 {
00313 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i] = NULL;
00314 }
00315 <font class="keywordflow">try</font>
00316 {
00317 <font class="keywordflow">for</font> ( i=0; i!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; i++ )
00318 {
00319 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i] = <font class="keyword">new</font> CTrack();
00320 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]->init( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a> );
00321 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.push_back(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]);
00322 }
00323 }
00324 <font class="keywordflow">catch</font> ( ESoundDriver & )
00325 {
00326 <font class="comment">// If the source generation failed, keep only the generated number of sources</font>
00327 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a> = i;
00328 <font class="comment">//delete _Tracks[i]; // Bug: the desctructor would not work because the source's name is invalid</font>
00329 }
00330
00331 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m4">_MaxNbTracks</a> = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>;
00332
00333 <font class="comment">// Init the reserve stuff.</font>
00334 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o4">_LowWaterMark</a> = 0;
00335 <font class="keywordflow">for</font> (i=0; i<<a class="code" href="namespaceNLSOUND.html#a82a14">NbSoundPriorities</a>; ++i)
00336 {
00337 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o2">_PriorityReserve</a>[i] = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>;
00338 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[i] = 0;
00339 }
00340
00341 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m6">_StartTime</a> = CTime::getLocalTime();
00342
00343 <font class="comment">// Create the background sound manager.</font>
00344 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a> = <font class="keyword">new</font> CBackgroundSoundManager();
00345
00346 <font class="comment">// Load the sound bank singleton</font>
00347 CSoundBank::instance()->load();
00348 <a class="code" href="debug_8h.html#a1">nlinfo</a>( <font class="stringliteral">"Initialized audio mixer with %u voices"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a> );
00349 }
00350
00351
00352 <font class="comment">// ******************************************************************</font>
<a name="l00353"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a40">00353</a> <font class="keywordtype">void</font> CAudioMixerUser::bufferUnloaded(IBuffer *buffer)
00354 {
00355 <font class="comment">// check all track to find a track playing this buffer.</font>
00356 uint i;
00357 <font class="keywordflow">for</font> ( i=0; i!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; ++i )
00358 {
00359 CTrack *track = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i];
00360 <font class="keywordflow">if</font> ( track && track->getSource())
00361 {
00362 <font class="keywordflow">if</font> (track->getSource()->getBuffer() == buffer)
00363 {
00364 track->getSource()->stop();
00365 }
00366 }
00367 }
00368
00369 }
00370
00371
00372 <font class="comment">// ******************************************************************</font>
00373
<a name="l00374"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a6">00374</a> <font class="keywordtype">void</font> CAudioMixerUser::enable( <font class="keywordtype">bool</font> b )
00375 {
00376 <font class="comment">// TODO : rewrite this method</font>
00377
00378 <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">false</font>);
00379 <font class="comment">/* if ( b )</font>
00380 <font class="comment"> {</font>
00381 <font class="comment"> // Reenable</font>
00382 <font class="comment"> _NbTracks = _MaxNbTracks;</font>
00383 <font class="comment"> }</font>
00384 <font class="comment"> else</font>
00385 <font class="comment"> {</font>
00386 <font class="comment"> // Disable</font>
00387 <font class="comment"> uint i;</font>
00388 <font class="comment"> for ( i=0; i!=_NbTracks; i++ )</font>
00389 <font class="comment"> {</font>
00390 <font class="comment"> if ( _Tracks[i] && ! _Tracks[i]->isAvailable() )</font>
00391 <font class="comment"> {</font>
00392 <font class="comment"> _Tracks[i]->getSource()->leaveTrack();</font>
00393 <font class="comment">// nlassert(_PlayingSources.find(_Tracks[i]->getSource()) != _PlayingSources.end());</font>
00394 <font class="comment">// _PlayingSources.erase(_Tracks[i]->getSource());</font>
00395 <font class="comment"> }</font>
00396 <font class="comment"> }</font>
00397 <font class="comment"> _NbTracks = 0;</font>
00398 <font class="comment"> }</font>
00399 <font class="comment">*/</font>
00400 }
00401
00402 <font class="comment">// ******************************************************************</font>
00403
<a name="l00404"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a37">00404</a> ISoundDriver* CAudioMixerUser::getSoundDriver()
00405 {
00406 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>;
00407 }
00408
00409 <font class="comment">// ******************************************************************</font>
00410
00411 <font class="comment">/*void CAudioMixerUser::computeEnvEffect( const CVector& listenerpos, bool force )</font>
00412 <font class="comment">{</font>
00413 <font class="comment"> // Find the first matching, linear search</font>
00414 <font class="comment"> vector<CEnvEffect*>::iterator ipe;</font>
00415 <font class="comment"> for ( ipe=_EnvEffects.begin(); ipe!=_EnvEffects.end(); ++ipe )</font>
00416 <font class="comment"> {</font>
00417 <font class="comment"> if ( (*ipe)->include( listenerpos ) )</font>
00418 <font class="comment"> {</font>
00419 <font class="comment"> // Set the effect only if it has changed</font>
00420 <font class="comment"> if ( (_CurEnvEffect != *ipe) || force )</font>
00421 <font class="comment"> {</font>
00422 <font class="comment"> _CurEnvEffect = *ipe;</font>
00423 <font class="comment"> _Listener.getListener()->setEnvironment( _CurEnvEffect->getEnvNum(), _CurEnvEffect->getEnvSize() );</font>
00424 <font class="comment"> nldebug( "AM: Listener environmental effect changed to %u", _CurEnvEffect->getEnvNum() );</font>
00425 <font class="comment"> }</font>
00426 <font class="comment"> return;</font>
00427 <font class="comment"> }</font>
00428 <font class="comment"> }</font>
00429 <font class="comment"></font>
00430 <font class="comment"> // If not found, set the default (only if it wasn't the default before)</font>
00431 <font class="comment"> if ( _CurEnvEffect != NULL )</font>
00432 <font class="comment"> {</font>
00433 <font class="comment"> _Listener.getListener()->setEnvironment( ENVFX_DEFAULT_NUM );</font>
00434 <font class="comment"> _CurEnvEffect = NULL;</font>
00435 <font class="comment"> nldebug( "AM: Listener environmental effect reset" );</font>
00436 <font class="comment"> }</font>
00437 <font class="comment"></font>
00438 <font class="comment">}</font>
00439 <font class="comment">*/</font>
00440
00441
00442 <font class="comment">// ******************************************************************</font>
00443
<a name="l00444"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#b0">00444</a> <font class="keywordtype">void</font> CAudioMixerUser::getFreeTracks( uint nb, CTrack **tracks )
00445 {
00446 std::vector<CTrack*>::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.end());
00447 <font class="keywordflow">for</font> (nb =0; first != last; ++first, ++nb)
00448 {
00449 tracks[nb] = *first;
00450 }
00451 }
00452
00453
00454 <font class="comment">// ******************************************************************</font>
00455
<a name="l00456"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a26">00456</a> <font class="keywordtype">void</font> CAudioMixerUser::applyListenerMove( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& listenerpos )
00457 {
00458 <font class="comment">// Store position</font>
00459 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o8">_ListenPosition</a> = listenerpos;
00460
00461 <font class="comment">// Environmental effect</font>
00462 <font class="comment">// computeEnvEffect( listenerpos );</font>
00463
00464 <font class="comment">/* // Environment sounds</font>
00465 <font class="comment"> if ( _EnvSounds != NULL )</font>
00466 <font class="comment"> {</font>
00467 <font class="comment"> _EnvSounds->recompute();</font>
00468 <font class="comment"> }</font>
00469 <font class="comment">*/</font>
00470 }
00471
00472 <font class="comment">// ******************************************************************</font>
00473
<a name="l00474"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a9">00474</a> <font class="keywordtype">void</font> CAudioMixerUser::reloadSampleBanks(<font class="keywordtype">bool</font> async)
00475 {
00476 CSampleBank::reload(async);
00477 }
00478
00479 <font class="comment">// ******************************************************************</font>
00480
<a name="l00481"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a42">00481</a> CTrack *CAudioMixerUser::getFreeTrack(CSimpleSource *source)
00482 {
00483 <font class="comment">// at least some track free ?</font>
00484 <font class="keywordflow">if</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.empty())
00485 {
00486 <font class="comment">// under the low water mark or under the reserve</font>
00487 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.size() > <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o4">_LowWaterMark</a>
00488 || <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[source->getPriority()] < <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o2">_PriorityReserve</a>[source->getPriority()] )
00489 {
00490 <font class="comment">// non discardable track or not too many waiting source</font>
00491 <font class="keywordflow">if</font> (source->getPriority() == <a class="code" href="namespaceNLSOUND.html#a82a10">HighestPri</a>
00492 || <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.size() > <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.size())
00493 {
00494 CTrack *ret = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.back();
00495 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.pop_back();
00496 ret->setSource(source);
00497 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[source->getPriority()]++;
00498 <font class="comment">// nldebug("Track %p assign to source %p", ret, ret->getSource());</font>
00499 <font class="keywordflow">return</font> ret;
00500 }
00501 }
00502 }
00503 <font class="comment">// try to find a track with a source cuttable</font>
00504 {
00505 <font class="keywordtype">float</font> d1, d2, t1, t2;
00506 d1 = (source->getPos() - <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o8">_ListenPosition</a>).norm();
00507 t1 = max(0.0f, 1-((d1-source->getSimpleSound()->getMinDistance()) / (source->getSimpleSound()->getMaxDistance() - source->getSimpleSound()->getMinDistance())));
00508
00509 <font class="keywordflow">for</font> (uint i=0; i<<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; ++i)
00510 {
00511 CSimpleSource *src2 = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]->getSource();
00512 <font class="keywordflow">if</font> (src2 != 0)
00513 {
00514 d2 = (src2->getPos() - <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o8">_ListenPosition</a>).norm();
00515 t2 = max(0.0f, 1-((d2-src2->getSimpleSound()->getMinDistance()) / (src2->getSimpleSound()->getMaxDistance() - src2->getSimpleSound()->getMinDistance())));
00516
00517 <font class="keyword">const</font> <font class="keywordtype">float</font> tfactor = 1.3f;
00518 <font class="keywordflow">if</font> (t1 > t2 * tfactor)
00519 <font class="comment">// if (d1 < d2)</font>
00520 {
00521 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Cutting source %p with source %p (%f > %f*%f)"</font>, src2, source, t1, tfactor, t2);
00522 <font class="comment">// on peut cuter cette voie !</font>
00523 src2->stop();
00524 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.empty())
00525 {
00526 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"No free track after cutting a playing sound source !"</font>);
00527 }
00528 <font class="keywordflow">else</font>
00529 {
00530 CTrack *ret = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.back();
00531 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.pop_back();
00532 ret->setSource(source);
00533 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Track %p assign to source %p"</font>, ret, ret->getSource());
00534 <font class="keywordflow">return</font> ret;
00535 }
00536 }
00537 }
00538 }
00539 }
00540
00541 <font class="keywordflow">return</font> 0;
00542 }
00543
<a name="l00544"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a43">00544</a> <font class="keywordtype">void</font> CAudioMixerUser::freeTrack(CTrack *track)
00545 {
00546 <a class="code" href="debug_8h.html#a6">nlassert</a>(track != 0);
00547 <a class="code" href="debug_8h.html#a6">nlassert</a>(track->getSource() != 0);
00548
00549 <font class="comment">// nldebug("Track %p free by source %p", track, track->getSource());</font>
00550
00551 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o3">_ReserveUsage</a>[track->getSource()->getPriority()]--;
00552 track->setSource(0);
00553 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.push_back(track);
00554 }
00555
00556
<a name="l00557"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#b1">00557</a> <font class="keywordtype">void</font> CAudioMixerUser::getPlayingSoundsPos(std::vector<std::pair<bool, NLMISC::CVector> > &pos)
00558 {
00559 <font class="keywordtype">int</font> nbplay = 0;
00560 <font class="keywordtype">int</font> nbmute = 0;
00561 <font class="keywordtype">int</font> nbsrc = 0;
00562
00563 TSourceContainer::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.end());
00564 <font class="keywordflow">for</font> (; first != last; ++first)
00565 {
00566 CSourceCommon *ps = *first;
00567 <font class="keywordflow">if</font> (ps->getType() == CSourceCommon::SOURCE_SIMPLE)
00568 {
00569 CSimpleSource *source = static_cast<CSimpleSource*>(*first);
00570 nbsrc++;
00571
00572 <font class="keywordflow">if</font> (source->isPlaying())
00573 {
00574 pos.push_back(make_pair(source->getTrack() == 0, source->getPos()));
00575
00576 <font class="keywordflow">if</font> (source->getTrack() == 0)
00577 nbmute++;
00578 <font class="keywordflow">else</font>
00579 {
00580 <font class="comment">// nldebug ("Source %p playing on track %p", source, source->getTrack());</font>
00581 nbplay ++;
00582 }
00583 }
00584 }
00585 }
00586
00587 <font class="comment">// nldebug("Total source : %d, playing : %d, muted : %d", nbsrc, nbplay, nbmute);</font>
00588 }
00589
00590
00591
<a name="l00592"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a19">00592</a> <font class="keywordtype">void</font> CAudioMixerUser::update()
00593 {
00594 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
00595 <font class="preprocessor"></font> <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> start = CTime::getPerformanceTime();
00596 <font class="preprocessor">#endif</font>
00597 <font class="preprocessor"></font>
00598 <font class="comment">// update the object.</font>
00599 {
00600 <font class="comment">// 1st, update the event list</font>
00601 {
00602 std::vector<std::pair<IMixerUpdate*, bool> >::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.end());
00603 <font class="keywordflow">for</font> (; first != last; ++first)
00604 {
00605 <font class="keywordflow">if</font> (first->second)
00606 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n0">_UpdateList</a>.insert(first->first);
00607 <font class="keywordflow">else</font>
00608 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n0">_UpdateList</a>.erase(first->first);
00609 }
00610 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.clear();
00611 }
00612 <font class="comment">// 2nd, do the update</font>
00613 {
00614 TMixerUpdateContainer::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n0">_UpdateList</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n0">_UpdateList</a>.end());
00615 <font class="keywordflow">for</font> (; first != last; ++first)
00616 {
00617 <font class="comment">// call the update method.</font>
00618 const_cast<IMixerUpdate*>(*first)->onUpdate();
00619 }
00620 }
00621 }
00622 <font class="comment">// send the event.</font>
00623 {
00624 <font class="comment">// 1st, update the event list</font>
00625 {
00626 std::vector<std::pair<NLMISC::TTime, IMixerEvent*> >::iterator first(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.begin()), last(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.end());
00627 <font class="keywordflow">for</font> (; first != last; ++first)
00628 {
00629 <font class="keywordflow">if</font> (first->first != 0)
00630 {
00631 <font class="comment">// add an event</font>
00632 <font class="comment">// nldebug ("Add event %p", first->second);</font>
00633 TTimedEventContainer::iterator it(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.insert(*first));
00634 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.insert(make_pair(first->second, it));
00635 }
00636 <font class="keywordflow">else</font>
00637 {
00638 <font class="comment">// remove the events</font>
00639 pair<TEventContainer::iterator, TEventContainer::iterator> <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a> = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.equal_range(first->second);
00640 TEventContainer::iterator first2(<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first), last2(<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second);
00641 <font class="keywordflow">for</font> (; first2 != last2; ++first2)
00642 {
00643 <font class="comment">// remove the event</font>
00644 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Remove event %p"</font>, first2->second->second);
00645 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.erase(first2->second);
00646 }
00647 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.erase(<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first, <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second);
00648 }
00649 }
00650
00651 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.clear();
00652 }
00653 <font class="comment">// 2nd, call the events</font>
00654 <a class="code" href="namespaceNLMISC.html#a183">TTime</a> now = <a class="code" href="classNLMISC_1_1CTime.html#d1">NLMISC::CTime::getLocalTime</a>();
00655 <font class="keywordflow">while</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.empty() && <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()->first <= now)
00656 {
00657 <font class="preprocessor">#ifdef _DEBUG</font>
00658 <font class="preprocessor"></font> CurrentEvent = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()->second;
00659 <font class="preprocessor">#endif</font>
00660 <font class="preprocessor"></font><font class="comment">// nldebug("Sending Event %p", _EventList.begin()->second);</font>
00661 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()->second->onEvent();
00662 TEventContainer::iterator it(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.lower_bound(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()->second));
00663 <font class="keywordflow">while</font> (it->first == <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin()->second)
00664 {
00665 <font class="keywordflow">if</font> (it->second == <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin())
00666 {
00667 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n3">_Events</a>.erase(it);
00668 <font class="keywordflow">break</font>;
00669 }
00670 it++;
00671 }
00672 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.erase(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n2">_EventList</a>.begin());
00673 <font class="preprocessor">#ifdef _DEBUG</font>
00674 <font class="preprocessor"></font> CurrentEvent = 0;
00675 <font class="preprocessor">#endif</font>
00676 <font class="preprocessor"></font> }
00677 }
00678
00679 <font class="comment">// update the background sound</font>
00680 <font class="comment">// _BackgroundSoundManager->update();</font>
00681
00682 <font class="comment">// Check all playing track and stop any terminated buffer.</font>
00683 <font class="keywordflow">for</font> (uint i=0; i<<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m3">_NbTracks</a>; ++i)
00684 {
00685 <font class="keywordflow">if</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]->isPlaying())
00686 {
00687 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]->getSource() != 0)
00688 {
00689 CSimpleSource *source = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m2">_Tracks</a>[i]->getSource();
00690 source->stop();
00691 }
00692
00693 <font class="comment">// try to play any waiting source.</font>
00694 <font class="keywordflow">if</font> (!<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.empty())
00695 {
00696 <font class="comment">// check if the source still exist before trying to play it</font>
00697 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.find(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.front()) != <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.end())
00698 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.front()->play();
00699 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Before POP Sources waiting : %u"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.size());
00700 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.pop_front();
00701 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"After POP Sources waiting : %u"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o1">_SourceWaitingForPlay</a>.size());
00702 }
00703 }
00704 }
00705
00706 <font class="comment">// Debug info</font>
00707 <font class="comment">/*uint32 i;</font>
00708 <font class="comment"> nldebug( "List of the %u tracks", _NbTracks );</font>
00709 <font class="comment"> for ( i=0; i!=_NbTracks; i++ )</font>
00710 <font class="comment"> {</font>
00711 <font class="comment"> CSimpleSource *su;</font>
00712 <font class="comment"> if ( su = _Tracks[i]->getSource() )</font>
00713 <font class="comment"> {</font>
00714 <font class="comment"> nldebug( "%u: %p %s %s %s %s, vol %u",</font>
00715 <font class="comment"> i, &_Tracks[i]->DrvSource, _Tracks[i]->isAvailable()?"FREE":"USED",</font>
00716 <font class="comment"> _Tracks[i]->isAvailable()?"":(su->isPlaying()?"PLAYING":"STOPPED"),</font>
00717 <font class="comment"> _Tracks[i]->isAvailable()?"":PriToCStr[su->getPriority()],</font>
00718 <font class="comment"> _Tracks[i]->isAvailable()?"":(su->getSound()?su->getSound()->getFilename().c_str():""),</font>
00719 <font class="comment"> (uint)(su->getGain()*100.0f) );</font>
00720 <font class="comment"> }</font>
00721 <font class="comment"> }*/</font>
00722
00723 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>->commit3DChanges();
00724
00725 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
00726 <font class="preprocessor"></font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m7">_UpdateTime</a> = CTime::ticksToSecond(CTime::getPerformanceTime() - start);
00727 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m9">_UpdateCount</a>++;
00728 <font class="preprocessor">#endif</font>
00729 <font class="preprocessor"></font>
00730 <font class="comment">/* // display the track using...</font>
00731 <font class="comment"> {</font>
00732 <font class="comment"> char tmp[2048] = "";</font>
00733 <font class="comment"> string str;</font>
00734 <font class="comment"></font>
00735 <font class="comment"> for (uint i=0; i<_NbTracks/2; ++i)</font>
00736 <font class="comment"> {</font>
00737 <font class="comment"> sprintf(tmp, "[%2u]%8p ", i, _Tracks[i]->getSource());</font>
00738 <font class="comment"> str += tmp;</font>
00739 <font class="comment"> }</font>
00740 <font class="comment"> nldebug((string("Status1: ")+str).c_str());</font>
00741 <font class="comment"> str = "";</font>
00742 <font class="comment"> for (i=_NbTracks/2; i<_NbTracks; ++i)</font>
00743 <font class="comment"> {</font>
00744 <font class="comment"> sprintf(tmp, "[%2u]%8p ", i, _Tracks[i]->getSource());</font>
00745 <font class="comment"> str += tmp;</font>
00746 <font class="comment"> }</font>
00747 <font class="comment">// nldebug((string("Status2: ")+str).c_str());</font>
00748 <font class="comment"> }</font>
00749 <font class="comment">*/</font>
00750 }
00751
00752
00753 <font class="comment">// ******************************************************************</font>
00754
<a name="l00755"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a11">00755</a> <a class="code" href="namespaceNLSOUND.html#a8">TSoundId</a> CAudioMixerUser::getSoundId( <font class="keyword">const</font> std::string &name )
00756 {
00757 <font class="keywordflow">return</font> CSoundBank::instance()->getSound(name);
00758 }
00759
00760 <font class="comment">// ******************************************************************</font>
00761
<a name="l00762"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a14">00762</a> <font class="keywordtype">void</font> CAudioMixerUser::addSource( CSourceCommon *source )
00763 {
00764 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.find(source) == <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.end());
00765 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.insert( source );
00766
00767 <font class="comment">// _profile(( "AM: ADDSOURCE, SOUND: %d, TRACK: %p, NAME=%s", source->getSound(), source->getTrack(),</font>
00768 <font class="comment">// source->getSound() && (source->getSound()->getName()!="") ? source->getSound()->getName().c_str() : "" ));</font>
00769
00770 }
00771
00772
00773 <font class="comment">// ******************************************************************</font>
00774
<a name="l00775"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a13">00775</a> USource *CAudioMixerUser::createSource( <a class="code" href="namespaceNLSOUND.html#a8">TSoundId</a> <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, <font class="keywordtype">bool</font> spawn, <a class="code" href="namespaceNLSOUND.html#a9">TSpawnEndCallback</a> cb, <font class="keywordtype">void</font> *userParam, CSoundContext *context )
00776 {
00777 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
00778 <font class="preprocessor"></font> <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> start = CTime::getPerformanceTime();
00779 <font class="preprocessor">#endif</font>
00780 <font class="preprocessor"></font>
00781 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: [%u]---------------------------------------------------------------"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a51">curTime</a>() ));
00782 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: CREATESOURCE: SOUND=%p, NAME=%s, TIME=%d"</font>, <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>->getName().c_str(), <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a51">curTime</a>() ));
00783 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>(( <font class="stringliteral">"AM: SOURCES: %d, PLAYING: %d, TRACKS: %d"</font>, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a22">getSourcesNumber</a>(), <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a23">getPlayingSourcesNumber</a>(), <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a24">getNumberAvailableTracks</a>() ));
00784
00785 <font class="keywordflow">if</font> ( <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a> == NULL )
00786 {
00787 <a class="code" href="audio__mixer__user_8cpp.html#a1">_profile</a>((<font class="stringliteral">"AM: FAILED CREATESOURCE"</font>));
00788 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"AM: Sound not created: invalid sound id"</font> );
00789 <font class="keywordflow">return</font> NULL;
00790 }
00791
00792 USource *ret = NULL;
00793
00794 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>->getSoundType() == CSound::SOUND_SIMPLE)
00795 {
00796 CSimpleSound *simpleSound = static_cast<CSimpleSound *>(id);
00797 <font class="comment">// This is a simple sound</font>
00798 <font class="keywordflow">if</font> (simpleSound->getBuffer() == NULL)
00799 {
00800 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Can't create the sound '%s'"</font>, simpleSound->getBuffername().c_str());
00801 <font class="keywordflow">return</font> NULL;
00802 }
00803
00804 <font class="comment">// Create source</font>
00805 CSimpleSource *source = <font class="keyword">new</font> CSimpleSource( simpleSound, spawn, cb, userParam);
00806
00807 <font class="comment">// nldebug("Mixer : source %p created", source);</font>
00808
00809 <font class="keywordflow">if</font> (source->getBuffer() != 0)
00810 {
00811 <font class="comment">// Link the position to the listener position if it'a stereo source</font>
00812 <font class="keywordflow">if</font> ( source->getBuffer()->isStereo() )
00813 {
00814 source->set3DPositionVector( &<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o8">_ListenPosition</a> );
00815 }
00816 }
00817 <font class="keywordflow">else</font>
00818 {
00819 <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">false</font>); <font class="comment">// FIXME</font>
00820 }
00821 ret = source;
00822 }
00823 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>->getSoundType() == CSound::SOUND_COMPLEX)
00824 {
00825 CComplexSound *complexSound = static_cast<CComplexSound*>(id);
00826 <font class="comment">// This is a pattern sound.</font>
00827 ret = <font class="keyword">new</font> CComplexSource(complexSound, spawn, cb, userParam);
00828 }
00829 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>->getSoundType() == CSound::SOUND_BACKGROUND)
00830 {
00831 <font class="comment">// This is a background sound.</font>
00832 CBackgroundSound *bgSound = static_cast<CBackgroundSound *>(id);
00833 ret = <font class="keyword">new</font> CBackgroundSource(bgSound, spawn, cb, userParam);
00834 }
00835 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>->getSoundType() == CSound::SOUND_CONTEXT)
00836 {
00837 <font class="comment">// This is a context sound.</font>
00838 <font class="keywordflow">if</font> (context != 0)
00839 {
00840 CContextSound *ctxSound = static_cast<CContextSound *>(id);
00841 <font class="comment">// nlassert(context != 0);</font>
00842 CSound *sound = ctxSound->getContextSound(*context);
00843 <font class="keywordflow">if</font> (sound != 0)
00844 {
00845 ret = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a12">createSource</a>(sound, spawn, cb, userParam);
00846 <font class="comment">// Set the volume of the source according to the context volume</font>
00847 <font class="keywordflow">if</font> (ret != 0)
00848 ret->setGain(ret->getGain() * ctxSound->getGain());
00849 }
00850 <font class="keywordflow">else</font>
00851 ret = 0;
00852 }
00853 <font class="keywordflow">else</font>
00854 ret = 0;
00855 }
00856 <font class="keywordflow">else</font>
00857 {
00858 <font class="comment">// nlassertex(false, ("Unknown sound class !"));</font>
00859 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Unknow sound class : %u"</font>, <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>->getSoundType());
00860 }
00861
00862 <font class="preprocessor">#if NL_PROFILE_MIXER</font>
00863 <font class="preprocessor"></font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m8">_CreateTime</a> = CTime::ticksToSecond(CTime::getPerformanceTime() - start);
00864 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m10">_CreateCount</a>++;
00865 <font class="preprocessor">#endif</font>
00866 <font class="preprocessor"></font>
00867 <font class="comment">//nldebug( "AM: Source created" ); </font>
00868 <font class="keywordflow">return</font> ret;
00869 }
00870
00871
00872 <font class="comment">// ******************************************************************</font>
00873
<a name="l00874"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a12">00874</a> USource *CAudioMixerUser::createSource( <font class="keyword">const</font> std::string &name, <font class="keywordtype">bool</font> spawn, <a class="code" href="namespaceNLSOUND.html#a9">TSpawnEndCallback</a> cb, <font class="keywordtype">void</font> *userParam, CSoundContext *context)
00875 {
00876 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a12">createSource</a>( <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a11">getSoundId</a>( name ), spawn, cb, userParam, context );
00877 }
00878
00879
00880 <font class="comment">// ******************************************************************</font>
00881
<a name="l00882"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a15">00882</a> <font class="keywordtype">void</font> CAudioMixerUser::removeSource( CSourceCommon *source )
00883 {
00884 <a class="code" href="debug_8h.html#a6">nlassert</a>( source != NULL );
00885
00886 size_t n = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.erase(source);
00887 <a class="code" href="debug_8h.html#a6">nlassert</a>(n == 1);
00888 }
00889
00890
00891 <font class="comment">// ******************************************************************</font>
00892
<a name="l00893"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a18">00893</a> <font class="keywordtype">void</font> CAudioMixerUser::selectEnvEffects( <font class="keyword">const</font> std::string &tag )
00894 {
00895 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<font class="keyword">false</font>, (<font class="stringliteral">"Not implemented yet"</font>));
00896 <font class="comment">/* // Select Env</font>
00897 <font class="comment"> vector<CEnvEffect*>::iterator ipe;</font>
00898 <font class="comment"> for ( ipe=_EnvEffects.begin(); ipe!=_EnvEffects.end(); ++ipe )</font>
00899 <font class="comment"> {</font>
00900 <font class="comment"> (*ipe)->selectEnv( tag );</font>
00901 <font class="comment"> }</font>
00902 <font class="comment"></font>
00903 <font class="comment"> // Compute</font>
00904 <font class="comment"> CVector pos;</font>
00905 <font class="comment"> _Listener.getPos( pos );</font>
00906 <font class="comment"> computeEnvEffect( pos, true );</font>
00907 <font class="comment">*/</font>
00908 }
00909
00910
00911 <font class="comment">// ******************************************************************</font>
00912
00913 <font class="comment">/*</font>
00914 <font class="comment">void CAudioMixerUser::loadEnvEffects( const char *filename )</font>
00915 <font class="comment">{</font>
00916 <font class="comment"> nlassert( filename != NULL );</font>
00917 <font class="comment"> nlinfo( "Loading environmental effects from %s...", filename );</font>
00918 <font class="comment"></font>
00919 <font class="comment"> // Unload previous env effects</font>
00920 <font class="comment"> vector<CEnvEffect*>::iterator ipe;</font>
00921 <font class="comment"> for ( ipe=_EnvEffects.begin(); ipe!=_EnvEffects.end(); ++ipe )</font>
00922 <font class="comment"> {</font>
00923 <font class="comment"> delete (*ipe);</font>
00924 <font class="comment"> }</font>
00925 <font class="comment"> _EnvEffects.clear();</font>
00926 <font class="comment"></font>
00927 <font class="comment"> string str = CPath::lookup( filename, false );</font>
00928 <font class="comment"></font>
00929 <font class="comment"> // Load env effects</font>
00930 <font class="comment"> CIFile file;</font>
00931 <font class="comment"> if ( !str.empty() && file.open(str) )</font>
00932 <font class="comment"> {</font>
00933 <font class="comment"> uint32 n = CEnvEffect::load( _EnvEffects, file );</font>
00934 <font class="comment"> nldebug( "AM: Loaded %u environmental effects", n );</font>
00935 <font class="comment"> }</font>
00936 <font class="comment"> else</font>
00937 <font class="comment"> {</font>
00938 <font class="comment"> nlwarning( "AM: Environmental effects file not found" );</font>
00939 <font class="comment"> }</font>
00940 <font class="comment">}</font>
00941 <font class="comment">*/</font>
00942
00943 <font class="comment">// ******************************************************************</font>
00944
<a name="l00945"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a7">00945</a> uint32 CAudioMixerUser::loadSampleBank(<font class="keywordtype">bool</font> async, <font class="keyword">const</font> std::string &filename, std::vector<std::string> *notfoundfiles )
00946 {
00947 <font class="comment">// nlassert( filename != NULL );</font>
00948
00949 string path = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o9">_SamplePath</a>;
00950 path.append(<font class="stringliteral">"/"</font>).append(filename);
00951
00952 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"Loading samples from %s..."</font>, path.c_str() );
00953
00954 CSampleBank* bank = CSampleBank::findSampleBank(path);
00955 <font class="keywordflow">if</font> (bank == NULL)
00956 {
00957 <font class="comment">// create a new sample bank</font>
00958 <font class="comment">//_CrtCheckMemory();</font>
00959 bank = <font class="keyword">new</font> CSampleBank(path, <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o5">_SoundDriver</a>);
00960 <font class="comment">//_CrtCheckMemory();</font>
00961 }
00962
00963 <font class="keywordflow">try</font>
00964 {
00965 bank->load(async);
00966 }
00967 <font class="keywordflow">catch</font> (Exception& e)
00968 {
00969 <font class="keywordflow">if</font> (notfoundfiles) {
00970 notfoundfiles->push_back(path);
00971 }
00972 string reason = e.what();
00973 <a class="code" href="debug_8h.html#a2">nlwarning</a>( <font class="stringliteral">"AM: Failed to load the samples: %s"</font>, reason.c_str() );
00974 }
00975
00976
00977 <font class="keywordflow">return</font> bank->countSamples();
00978 }
00979
<a name="l00980"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a8">00980</a> <font class="keywordtype">bool</font> CAudioMixerUser::unloadSampleBank( <font class="keyword">const</font> std::string &filename)
00981 {
00982 string path = <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o9">_SamplePath</a>;
00983 path.append(<font class="stringliteral">"/"</font>).append(filename);
00984
00985 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"Unloading samples from %s..."</font>, path.c_str() );
00986 CSampleBank *pbank = CSampleBank::findSampleBank(path);
00987
00988 <font class="keywordflow">if</font> (pbank != NULL)
00989 {
00990 <font class="comment">// ok, the bank exist.</font>
00991 <font class="keywordflow">return</font> pbank->unload();
00992 }
00993 <font class="keywordflow">else</font>
00994 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00995
00996 }
00997
00998 <font class="comment">// ******************************************************************</font>
00999
<a name="l01000"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a20">01000</a> <font class="keywordtype">void</font> CAudioMixerUser::getSoundNames( std::vector<std::string>& names )<font class="keyword"> const</font>
01001 <font class="keyword"></font>{
01002 CSoundBank::instance()->getNames(names);
01003 }
01004
01005
01006 <font class="comment">// ******************************************************************</font>
01007
<a name="l01008"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a23">01008</a> uint CAudioMixerUser::getPlayingSourcesNumber()<font class="keyword"> const</font>
01009 <font class="keyword"></font>{
01010 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m1">_PlayingSources</a>;
01011 }
01012
01013 <font class="comment">// ******************************************************************</font>
01014
<a name="l01015"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a24">01015</a> uint CAudioMixerUser::getNumberAvailableTracks()<font class="keyword"> const</font>
01016 <font class="keyword"></font>{
01017 <font class="keywordflow">return</font> <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o0">_FreeTracks</a>.size();
01018 }
01019
01020
01021 <font class="comment">// ******************************************************************</font>
01022
<a name="l01023"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a25">01023</a> string CAudioMixerUser::getSourcesStats()<font class="keyword"> const</font>
01024 <font class="keyword"></font>{
01025 <font class="comment">// TODO : rewrite log output</font>
01026
01027 string <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
01028 TSourceContainer::iterator ips;
01029 <font class="keywordflow">for</font> ( ips=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.begin(); ips!=<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#m0">_Sources</a>.end(); ++ips )
01030 {
01031 <font class="keywordflow">if</font> ( (*ips)->isPlaying() )
01032 {
01033 <font class="comment">// char line [80];</font>
01034
01035 <font class="comment">/* nlassert( (*ips)->getSound() && (*ips)->getSimpleSound()->getBuffer() );</font>
01036 <font class="comment"> smprintf( line, 80, "%s: %u%% %s %s",</font>
01037 <font class="comment"> (*ips)->getSound()->getName().c_str(),</font>
01038 <font class="comment"> (uint32)((*ips)->getGain()*100.0f),</font>
01039 <font class="comment"> (*ips)->getBuffer()->isStereo()?"ST":"MO",</font>
01040 <font class="comment"> PriToCStr[(*ips)->getPriority()] );</font>
01041 <font class="comment"> s += string(line) + "\n";</font>
01042 <font class="comment">*/</font> }
01043 }
01044 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
01045
01046 }
01047
01048 <font class="comment">// ******************************************************************</font>
01049 <font class="comment">/*</font>
01050 <font class="comment">void CAudioMixerUser::loadEnvSounds( const char *filename, UEnvSound **treeRoot )</font>
01051 <font class="comment">{</font>
01052 <font class="comment"> nlassert( filename != NULL );</font>
01053 <font class="comment"> nlinfo( "Loading environment sounds from %s...", filename );</font>
01054 <font class="comment"></font>
01055 <font class="comment"> string str = CPath::lookup( filename, false );</font>
01056 <font class="comment"></font>
01057 <font class="comment"> CIFile file;</font>
01058 <font class="comment"> if ( !str.empty() && file.open( str ) )</font>
01059 <font class="comment"> {</font>
01060 <font class="comment"> uint32 n = 0; //CEnvSoundUser::load( _EnvSounds, file );</font>
01061 <font class="comment"> nldebug( "AM: Loaded %u environment sounds", n );</font>
01062 <font class="comment"> }</font>
01063 <font class="comment"> else</font>
01064 <font class="comment"> {</font>
01065 <font class="comment"> nlwarning( "AM: Environment sounds file not found: %s", filename );</font>
01066 <font class="comment"> }</font>
01067 <font class="comment"> if ( treeRoot != NULL )</font>
01068 <font class="comment"> {</font>
01069 <font class="comment"> *treeRoot = _EnvSounds;</font>
01070 <font class="comment"> }</font>
01071 <font class="comment">}</font>
01072 <font class="comment">*/</font>
01073
01074 <font class="comment">// ******************************************************************</font>
01075
<a name="l01076"></a><a class="code" href="structNLSOUND_1_1CompareSources.html">01076</a> <font class="keyword">struct </font>CompareSources : <font class="keyword">public</font> binary_function<const CSimpleSource*, const CSimpleSource*, bool>
01077 {
01078 <font class="comment">// Constructor</font>
<a name="l01079"></a><a class="code" href="structNLSOUND_1_1CompareSources.html#a0">01079</a> <a class="code" href="structNLSOUND_1_1CompareSources.html#a0">CompareSources</a>( <font class="keyword">const</font> CVector &pos ) : <a class="code" href="structNLSOUND_1_1CompareSources.html#m0">_Pos</a>(pos) {}
01080
01081 <font class="comment">// Operator()</font>
<a name="l01082"></a><a class="code" href="structNLSOUND_1_1CompareSources.html#a1">01082</a> <font class="keywordtype">bool</font> <a class="code" href="structNLSOUND_1_1CompareSources.html#a1">operator()</a>( <font class="keyword">const</font> CSimpleSource *s1, <font class="keyword">const</font> CSimpleSource *s2 )
01083 {
01084 <font class="keywordflow">if</font> (s1->getPriority() < s2->getPriority())
01085 {
01086 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01087 }
01088 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (s1->getPriority() == s2->getPriority())
01089 {
01090 <font class="comment">// Equal priority, test distances to the listener</font>
01091 <font class="keyword">const</font> CVector &src1pos = s1->getPos();
01092 <font class="keyword">const</font> CVector &src2pos = s2->getPos();;
01093 <font class="keywordflow">return</font> ( (src1pos-<a class="code" href="structNLSOUND_1_1CompareSources.html#m0">_Pos</a>).sqrnorm() < (src2pos-<a class="code" href="structNLSOUND_1_1CompareSources.html#m0">_Pos</a>).sqrnorm() );
01094 }
01095 <font class="keywordflow">else</font>
01096 {
01097 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01098 }
01099 }
01100
01101 <font class="comment">// Listener pos</font>
<a name="l01102"></a><a class="code" href="structNLSOUND_1_1CompareSources.html#m0">01102</a> <font class="keyword">const</font> CVector &<a class="code" href="structNLSOUND_1_1CompareSources.html#m0">_Pos</a>;
01103 };
01104
01105
01106 <font class="comment">// ******************************************************************</font>
<a name="l01107"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a10">01107</a> uint32 CAudioMixerUser::getLoadedSampleSize()
01108 {
01109 <font class="keywordflow">return</font> CSampleBank::getTotalByteSize();
01110 }
01111
01112
01113 <font class="comment">// ******************************************************************</font>
01114 <font class="comment">/*</font>
01115 <font class="comment">void CAudioMixerUser::redispatchSourcesToTrack()</font>
01116 <font class="comment">{</font>
01117 <font class="comment">*/</font> <font class="comment">// TODO : rewrite ?</font>
01118 <font class="comment">/*</font>
01119 <font class="comment"> if ( _NbTracks == 0 )</font>
01120 <font class="comment"> {</font>
01121 <font class="comment"> return;</font>
01122 <font class="comment"> }</font>
01123 <font class="comment"></font>
01124 <font class="comment"> _profile(( "AM: [%u]---------------------------------------------------------------", curTime() ));</font>
01125 <font class="comment"> _profile(( "AM: Redispatching sources" ));</font>
01126 <font class="comment"> </font>
01127 <font class="comment"> const CVector &listenerpos = _Listener.getPos();</font>
01128 <font class="comment"></font>
01129 <font class="comment"> // Get a copy of the sources set (we will modify it)</font>
01130 <font class="comment"> static TSourceContainer sources_copy; </font>
01131 <font class="comment"> sources_copy = _PlayingSources;</font>
01132 <font class="comment"> // FIXME: SWAPTEST</font>
01133 <font class="comment"> //nlassert( sources_copy.size() >= _NbTracks );</font>
01134 <font class="comment"></font>
01135 <font class="comment"> // Select the nbtracks "smallest" sources (the ones that have the higher priorities)</font>
01136 <font class="comment"> TSourceContainer::iterator ips;</font>
01137 <font class="comment"> static TSourceContainer selected_sources;</font>
01138 <font class="comment"> uint32 i;</font>
01139 <font class="comment"></font>
01140 <font class="comment"> selected_sources.clear();</font>
01141 <font class="comment"></font>
01142 <font class="comment"> // Select the sources</font>
01143 <font class="comment"></font>
01144 <font class="comment"> // Select the nbtracks "smallest" sources (the ones that have the higher priorities)</font>
01145 <font class="comment"> // FIXME: SWAPTEST</font>
01146 <font class="comment"> //for ( i=0; i!=_NbTracks; i++ )</font>
01147 <font class="comment"> // TODO : optimize : this is a very BAD PERFORMANCE code</font>
01148 <font class="comment"> while (!sources_copy.empty() && (selected_sources.size() < _NbTracks))</font>
01149 <font class="comment"> {</font>
01150 <font class="comment"> ips = min_element( sources_copy.begin(), sources_copy.end(), CompareSources( listenerpos ) );</font>
01151 <font class="comment"></font>
01152 <font class="comment"> if ((*ips)->isPlaying())</font>
01153 <font class="comment"> {</font>
01154 <font class="comment"> selected_sources.insert( *ips );</font>
01155 <font class="comment"> }</font>
01156 <font class="comment"></font>
01157 <font class="comment"> sources_copy.erase( ips );</font>
01158 <font class="comment"> }</font>
01159 <font class="comment"></font>
01160 <font class="comment"> // Clear the current tracks where the sources are not selected anymore</font>
01161 <font class="comment"> _profile(( "AM: Total sources: %u", _PlayingSources.size() ));</font>
01162 <font class="comment"> _profile(( "AM: Selected sources: %u", selected_sources.size() ));</font>
01163 <font class="comment"> for ( i=0; i!=_NbTracks; i++ )</font>
01164 <font class="comment"> {</font>
01165 <font class="comment"> // FIXME: SWAPTEST</font>
01166 <font class="comment"> if ( _Tracks[i] && ! _Tracks[i]->isAvailable() )</font>
01167 <font class="comment"> {</font>
01168 <font class="comment"> // Optimization note: instead of searching the source in selected_sources, we could have</font>
01169 <font class="comment"> // set a boolean in the source object and tested it.</font>
01170 <font class="comment"> if ( (ips = selected_sources.find( _Tracks[i]->getSource() )) == selected_sources.end() )</font>
01171 <font class="comment"> {</font>
01172 <font class="comment"> // There will be a new source in this track</font>
01173 <font class="comment"> _profile(( "AM: TRACK: %p: REPLACED, SOURCE: %p", _Tracks[i], _Tracks[i]->getSource() ));</font>
01174 <font class="comment"> if (_Tracks[i]->getSource() != 0)</font>
01175 <font class="comment"> {</font>
01176 <font class="comment"> _Tracks[i]->getSource()->leaveTrack();</font>
01177 <font class="comment">// nlassert(_PlayingSources.find(_Tracks[i]->getSource()) != _PlayingSources.end());</font>
01178 <font class="comment"> _PlayingSources.erase(_Tracks[i]->getSource());</font>
01179 <font class="comment"> }</font>
01180 <font class="comment"> }</font>
01181 <font class="comment"> else</font>
01182 <font class="comment"> {</font>
01183 <font class="comment"> // The track will remain unchanged</font>
01184 <font class="comment"> selected_sources.erase( ips );</font>
01185 <font class="comment"> _profile(( "AM: TRACK: %p: UNCHANGED, SOURCE: %p", _Tracks[i], _Tracks[i]->getSource() ));</font>
01186 <font class="comment"> }</font>
01187 <font class="comment"> }</font>
01188 <font class="comment"> else</font>
01189 <font class="comment"> {</font>
01190 <font class="comment"> _profile(( "AM: TRACK: %p: FREE", _Tracks[i] ));</font>
01191 <font class="comment"> }</font>
01192 <font class="comment"> }</font>
01193 <font class="comment"></font>
01194 <font class="comment"> if (!selected_sources.empty())</font>
01195 <font class="comment"> {</font>
01196 <font class="comment"> // Now, only the sources to add into the tracks remain in selected_sources</font>
01197 <font class="comment"> CTrack *track [MAX_TRACKS]; // a little bit more than needed (avoiding a "new")</font>
01198 <font class="comment"> getFreeTracks( selected_sources.size(), track );</font>
01199 <font class="comment"></font>
01200 <font class="comment"> _profile(( "AM: Remaining sources: %u", selected_sources.size() ));</font>
01201 <font class="comment"></font>
01202 <font class="comment"> for (i=0, ips=selected_sources.begin(); ips!=selected_sources.end(); ++ips )</font>
01203 <font class="comment"> {</font>
01204 <font class="comment"> // FIXME: SWAPTEST</font>
01205 <font class="comment"> (*ips)->enterTrack( track[i] );</font>
01206 <font class="comment">// nlassert(_PlayingSources.find(*ips) == _PlayingSources.end());</font>
01207 <font class="comment">// _PlayingSources.insert(*ips);</font>
01208 <font class="comment"> // _profile(( "AM: TRACK: %p: ASSIGNED, SOURCE: %p", track[i], track[i]->getSource() ));</font>
01209 <font class="comment"> _profile(( "AM: TRACK: %p: ASSIGNED, SOURCE: %p", track[i], *ips ));</font>
01210 <font class="comment"> i++;</font>
01211 <font class="comment"> }</font>
01212 <font class="comment"> }</font>
01213 <font class="comment">*/</font>
01214 <font class="comment">//}</font>
01215
<a name="l01216"></a><a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#a16">01216</a> <font class="keywordtype">void</font> CAudioMixerUser::setListenerPos (<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &pos)
01217 {
01218 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o7">_Listener</a>.setPos(pos);
01219 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>->setListenerPosition(pos);
01220 }
01221
01222 <a class="code" href="command_8h.html#a0">NLMISC_COMMAND</a> (displaySoundInfo, <font class="stringliteral">"Display information about the audio mixer"</font>, <font class="stringliteral">""</font>)
01223 {
01224 <font class="keywordflow">if</font>(args.size() != 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
01225
01226 <font class="keywordflow">if</font> (CAudioMixerUser::instance() == NULL)
01227 {
01228 log.displayNL (<font class="stringliteral">"No audio mixer available"</font>);
01229 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01230 }
01231
01232 log.displayNL (<font class="stringliteral">"%d tracks, MAX_TRACKS = %d, contains:"</font>, CAudioMixerUser::instance()->_NbTracks, <a class="code" href="namespaceNLSOUND.html#a16">MAX_TRACKS</a>);
01233
01234 <font class="keywordflow">for</font> (uint i = 0; i < CAudioMixerUser::instance()->_NbTracks; i++)
01235 {
01236 <font class="keywordflow">if</font> (CAudioMixerUser::instance()->_Tracks[i] == NULL)
01237 {
01238 log.displayNL (<font class="stringliteral">"Track %d is NULL"</font>, i);
01239 }
01240 <font class="keywordflow">else</font>
01241 {
01242 log.displayNL (<font class="stringliteral">"Track %d %s available and %s playing."</font>, i, (CAudioMixerUser::instance()->_Tracks[i]->isAvailable()?<font class="stringliteral">"is"</font>:<font class="stringliteral">"is not"</font>), (CAudioMixerUser::instance()->_Tracks[i]->isPlaying()?<font class="stringliteral">"is"</font>:<font class="stringliteral">"is not"</font>));
01243 <font class="keywordflow">if</font> (CAudioMixerUser::instance()->_Tracks[i]->getSource() == NULL)
01244 {
01245 log.displayNL (<font class="stringliteral">" CUserSource is NULL"</font>);
01246 }
01247 <font class="keywordflow">else</font>
01248 {
01249 <font class="keyword">const</font> CVector &pos = CAudioMixerUser::instance()->_Tracks[i]->getSource()->getPos();
01250 string bufname;
01251 <font class="keywordflow">if</font> (CAudioMixerUser::instance()->_Tracks[i]->getSource()->getBuffer())
01252 bufname = CAudioMixerUser::instance()->_Tracks[i]->getSource()->getBuffer()->getName();
01253 log.displayNL (<font class="stringliteral">" CUserSource is id %d buffer name '%s' pos %f %f %f"</font>, CAudioMixerUser::instance()->_Tracks[i]->getSource()->getSound(), bufname.c_str(), pos.x, pos.y, pos.z);
01254 }
01255 }
01256 }
01257
01258 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01259 }
01260
01261 <font class="keywordtype">void</font> CAudioMixerUser::registerBufferAssoc(CSound *sound, IBuffer *buffer)
01262 {
01263 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o10">_BufferToSources</a>[buffer].push_back(sound);
01264 }
01265
01266 <font class="keywordtype">void</font> CAudioMixerUser::unregisterBufferAssoc(CSound *sound, IBuffer *buffer)
01267 {
01268 TBufferToSourceContainer::iterator it(<a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o10">_BufferToSources</a>.find(buffer));
01269 <font class="keywordflow">if</font> (it != <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o10">_BufferToSources</a>.end())
01270 {
01271 std::vector<CSound*>::iterator first(it->second.begin()), last(it->second.end());
01272
01273 <font class="keywordflow">for</font> (; first != last; ++first)
01274 {
01275 <font class="keywordflow">if</font> (*first == sound)
01276 {
01277 it->second.erase(first);
01278 <font class="keywordflow">break</font>;
01279 }
01280 }
01281 }
01282 }
01283
01284
01286 <font class="keywordtype">void</font> CAudioMixerUser::registerUpdate(CAudioMixerUser::IMixerUpdate *pmixerUpdate)
01287 {
01288 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.push_back(make_pair(pmixerUpdate, <font class="keyword">true</font>));
01289 }
01291 <font class="keywordtype">void</font> CAudioMixerUser::unregisterUpdate(CAudioMixerUser::IMixerUpdate *pmixerUpdate)
01292 {
01293 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n1">_UpdateEventList</a>.push_back(make_pair(pmixerUpdate, <font class="keyword">false</font>));
01294 }
01295
01297 <font class="keywordtype">void</font> CAudioMixerUser::addEvent( CAudioMixerUser::IMixerEvent *pmixerEvent, <font class="keyword">const</font> NLMISC::TTime &date)
01298 {
01299 <font class="comment">// nldebug("Adding event %p", pmixerEvent);</font>
01300 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.push_back(make_pair(date, pmixerEvent));
01301 }
01303 <font class="keywordtype">void</font> CAudioMixerUser::removeEvents( CAudioMixerUser::IMixerEvent *pmixerEvent)
01304 {
01305 <font class="comment">// nldebug("Removing event %p", pmixerEvent);</font>
01306 <font class="comment">// store the pointer fot future removal.</font>
01307 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#n4">_EventListUpdate</a>.push_back(make_pair(0, pmixerEvent));
01308 }
01309
01310 <font class="keywordtype">void</font> CAudioMixerUser::setBackgroundFlags(<font class="keyword">const</font> TBackgroundFlags &backgroundFlags)
01311 {
01312 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>->setBackgroundFlags(backgroundFlags);
01313 }
01314
01315 <font class="keywordtype">void</font> CAudioMixerUser::loadBackgroundSoundFromRegion (<font class="keyword">const</font> <a class="code" href="classNLLIGO_1_1CPrimRegion.html">NLLIGO::CPrimRegion</a> &region)
01316 {
01317 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>->loadSoundsFromRegion(region);
01318 }
01319
01320 <font class="keywordtype">void</font> CAudioMixerUser::loadBackgroundEffectsFromRegion (<font class="keyword">const</font> <a class="code" href="classNLLIGO_1_1CPrimRegion.html">NLLIGO::CPrimRegion</a> &region)
01321 {
01322 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>->loadEffecsFromRegion(region);
01323 }
01324 <font class="keywordtype">void</font> CAudioMixerUser::loadBackgroundSamplesFromRegion (<font class="keyword">const</font> <a class="code" href="classNLLIGO_1_1CPrimRegion.html">NLLIGO::CPrimRegion</a> &region)
01325 {
01326 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>->loadSamplesFromRegion(region);
01327 }
01328
01329
01330 <font class="keywordtype">void</font> CAudioMixerUser::playBackgroundSound ()
01331 {
01332 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>->play ();
01333 }
01334
01335 <font class="keywordtype">void</font> CAudioMixerUser::stopBackgroundSound ()
01336 {
01337 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>->stop ();
01338 }
01339
01340 <font class="keywordtype">void</font> CAudioMixerUser::loadBackgroundSound (<font class="keyword">const</font> std::string &continent)
01341 {
01342 <a class="code" href="classNLSOUND_1_1CAudioMixerUser.html#o6">_BackgroundSoundManager</a>->load (continent);
01343 }
01344
01345 } <font class="comment">// NLSOUND</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|