forked from bbpanzu/bb-fnf-mods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnd.hx
1288 lines (1045 loc) · 26.1 KB
/
Snd.hx
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
import faxe.Faxe;
import SndTV;
using StringTools;
//praise delahee, i'll figure out what this shit means later!
class Channel {
public var name:String;
public var onEnd : Void -> Void = null;
public var isDebug = false;
var started = true;
var paused = false;
var disposed = false;
var completed = false;
inline function new( ?name:String = null ){
if ( name == null )
this.name = C.EMPTY_STRING;
else
this.name = name;
}
public function poolBack(){
#if false
//trace("pool back");
#end
started = false;
paused = false;
disposed = true;
completed = true;
isDebug = false;
}
public function reset(){
started = false;
paused = false;
disposed = false;
completed = false;
isDebug = false;
}
public function stop(){
started = false;
}
public function pause(){
paused = false;
started = true;
}
public function resume(){
paused = true;
started = true;
}
public function dispose(){
setVolume(0);//prevent any further listen
disposed = true;
onEnd = null;
}
public function onComplete() {
completed = true;
#if !prod
//trace("onComplete " + haxe.Timer.stamp() );
#end
//stop();
if( onEnd!=null ) {
var cb = onEnd;
onEnd = null;
cb();
}
}
public function isComplete(){
#if !prod
if ( completed ){
//trace("already completed");
}
if ( started ){
//trace("started ok");
}
#end
return completed || (started && !isPlaying());
}
//returns in secs
public function getPlayCursorSec() : Float {
throw "override me";
return 0.0;
}
//returns in secs
public function getPlayCursorMs() : Float {
throw "override me";
return 0.0;
}
public function setPlayCursorSec(posSec:Float) {
setPlayCursorMs( posSec * 1000.0 );
}
public function setPlayCursorMs(posMs:Float) {
throw "override me";
}
public function isPlaying(){
throw "override me";
return false;
}
public function getVolume():Float{
throw "override me";
return 0.0;
}
public function setVolume(v:Float){
throw "override me";
}
public function setNbLoops(nb:Int){
}
}
class ChannelEventInstance extends Channel {//basically a sound instance
public static var EMPTY_STRING = "";
public var data : FmodStudioEventInstanceRef = null;
function new(?name:String){
super(name);
started = false;
//instance does not start playing
}
public static var pool = {
var p = new hxd.Pool<ChannelEventInstance>(ChannelEventInstance);
//p.actives = null;
p;
}
public static function alloc(data : FmodStudioEventInstanceRef, ?name:String=null ){
var s = pool.alloc();
s.reset();
s.data = data;
s.name = name == null ? EMPTY_STRING : name;
return s;
}
public static function delete( c : ChannelEventInstance){
c.dispose();
pool.delete(c);
}
public function getData() return data;
public override function dispose(){
super.dispose();
if ( data != null){
data.release();
data = null;
}
}
public override function poolBack(){
super.poolBack();
ChannelEventInstance.delete(this);
}
public override function stop(){
if (data != null) data.stop(FmodStudioStopMode.StopAllowFadeout());
super.stop();
}
public override function pause(){
super.pause();
if(data!=null) data.setPaused(true);
}
public override function resume(){
super.resume();
if(data!=null) data.setPaused(false);
}
public override function isPlaying(){
if ( completed ) return false;
if ( data == null ) {
//#if !prod
//trace("[CEI]no data " + name);
//#end
return false;
}
var b : Bool = false;
data.getPaused( Cpp.addr(b));
#if !prod
//trace("getPaused:"+b);
#end
return !b;
}
//returns in secs
public override function getPlayCursorSec() : Float {
if ( data == null ) return 0.0;
var pos : Int = 0;
var res = data.getTimelinePosition( Cpp.addr(pos) );
var posF : Float = 1.0 * pos / 1000.0;
return posF;
}
//returns in secs
public override function getPlayCursorMs() : Float {
if ( data == null ) return 0.0;
var pos : Int = 0;
var res = data.getTimelinePosition( Cpp.addr(pos) );
return 1.0 * pos;
}
public override function setPlayCursorMs(posMs:Float) {
if ( data == null ) return;
if ( posMs < 0.0) posMs = 0.0;
var pos : Int = 0;
pos = Math.round( posMs );
var res = data.setTimelinePosition( pos );
if ( res != FMOD_OK){
#if debug
//trace("[SND][Channel]{"+name+"} Repositionning S err " + FaxeRef.fmodResultToString(res)+" to :"+pos+" ("+posMs+")");
#end
}
#if debug
//trace("setPlayCursorMs "+posMs);
#end
}
public override function setNbLoops(nb:Int){
}
public override function getVolume() : Float{
if (data == null ) return 0.0;
var vol : cpp.Float32 = 0.0;
var fvol : cpp.Float32 = 0.0;
var res = data.getVolume( Cpp.addr(vol),Cpp.addr(fvol) );
if ( res != FMOD_OK){
#if debug
//trace("[SND][Channel]{"+name+"} getVolume err " + FaxeRef.fmodResultToString(res));
#end
}
return vol;
}
public override function setVolume(v:Float){
if (data == null ){
//#if debug
//trace("no data for "+name);
//#end
return;
}
var res = data.setVolume( hxd.Math.clamp(v,0,1) );
if ( res != FMOD_OK){
//#if debug
//trace("[SND][Channel]{"+name+"} setVolume err " + FaxeRef.fmodResultToString(res));
//#end
}
else {
//if ( isDebug ){
//#if !prod
//trace("[SND][Channel]{"+name+"} setVolume ok " + v);
//#end
//}
}
}
}
class ChannelLowLevel extends Channel{
public static var EMPTY_STRING = "";
public var data : FmodChannelRef = null;
function new( data : FmodChannelRef, ?name:String ){
super(name);
this.data = data;
started = true;
}
public static var pool = {
var p = new hxd.Pool<ChannelLowLevel>(ChannelLowLevel);
//p.actives = null;
p;
}
public static function alloc(data : FmodChannelRef, ?name ){
var s = pool.alloc();
s.reset();
s.data = data;
s.name = name == null?EMPTY_STRING:name;
return s;
}
public static function delete( c : ChannelLowLevel){
c.dispose();
pool.delete(c);
}
public function getData(){
return data;
}
public override function poolBack(){
super.poolBack();
ChannelLowLevel.delete(this);
}
public override function stop(){
if (data != null) data.stop();
super.stop();
}
public override function pause(){
super.pause();
if(data!=null) data.setPaused(true);
}
public override function resume(){
super.resume();
if(data!=null) data.setPaused(false);
}
public override function dispose(){
super.dispose();
data = null;
}
public override function isPlaying(){
if ( completed ) return false;
if (data == null) {
//#if !prod
//trace("no data no playing! "+name);
//#end
return false;
}
var b : Bool = false;
var res = data.isPlaying( Cpp.addr(b));
if ( res != FMOD_OK ){
//#if debug
//trace("[SND][ChannelLowLevel]{"+name+"} isPlaying err " + FaxeRef.fmodResultToString(res));
//#end
return false;
}
return b;
}
//returns in secs
public override function getPlayCursorSec() : Float {
if (data == null) return 0.0;
var pos : cpp.UInt32 = 0;
var res = data.getPosition( Cpp.addr(pos), faxe.Faxe.FmodTimeUnit.FTM_MS );
var posF : Float = 1.0 * pos * 1000.0;
return posF;
}
//returns in secs
public override function getPlayCursorMs() : Float {
if (data == null) return 0.0;
var pos : cpp.UInt32 = 0;
var res = data.getPosition( Cpp.addr(pos), faxe.Faxe.FmodTimeUnit.FTM_MS );
return 1.0 * pos;
}
public override function setPlayCursorMs(posMs:Float) {
if (data == null) return;
if ( posMs < 0.0) posMs = 0.0;
var posU : cpp.UInt32 = 0;
posU = Math.round( posMs );
var res = data.setPosition( posU, FmodTimeUnit.FTM_MS );
if ( res != FMOD_OK){
//#if debug
//trace("[SND][Channel]{"+name+"} Repositionning S err " + FaxeRef.fmodResultToString(res)+" to :"+posU+" ("+posMs+")");
//#end
}
}
public override function setNbLoops(nb:Int){
if (data == null) return;
data.setMode(FmodMode.FMOD_LOOP_NORMAL);
data.setLoopCount(nb);
}
public override function getVolume():Float{
if (data == null) return 0.0;
var vol : cpp.Float32 = 0.0;
var res = data.getVolume( Cpp.addr(vol) );
if ( res != FMOD_OK){
//#if debug
//trace("[SND][Channel]{"+name+"} getVolume err " + FaxeRef.fmodResultToString(res));
//#end
}
return vol;
}
public override function setVolume(v:Float){
if (data == null) {
//if ( isDebug ){
//#if !prod
//trace("[SND][Channel]{"+name+"} setVolume no data");
//#end
//}
return;
}
var vcl = hxd.Math.clamp(v, 0, 1);
var res = data.setVolume( vcl );
if ( res != FMOD_OK){
//#if !prod
//trace("[SND][Channel]{"+name+"} setVolume err " + FaxeRef.fmodResultToString(res));
//#end
}
else {
if ( isDebug ){
//#if !prod
//trace("[SND][Channel]{"+name+"} setVolume ok " + v+" corrected:"+vcl);
//#end
}
}
}
}
class Sound {
/**
* length is in seconds
*/
public var name = "";
public var length(get, null) : Float;
public var id3 : Dynamic = null;
public var isDebug = false;
var disposed = false;
function new( ?name:String=null ){
disposed = false;
}
function get_length() : Float{
return 0.0;
}
//returns in msec
public function getDuration(): Float{
return getDurationMs();
}
public function getDurationSec() : Float{
return length;
}
public function getDurationMs() : Float{
return length * 1000.0;
}
public function dispose(){
if (disposed) return;
disposed = true;
}
public function play( ?offsetMs : Float = 0.0, ?nbLoops:Int = 1, ?volume:Float = 1.0 ) : Channel {
return null;
}
}
class SoundLowLevel extends Sound{
public var data : FmodSoundRef = null;
public function new( data : cpp.Pointer<faxe.Faxe.FmodSound>, ?name:String = null ){
super(name);
this.data = Cpp.ref(data);
}
public function getData(){
return data;
}
public override function dispose(){
super.dispose();
if ( Snd.released ) {
data = null;
return;
}
if(data!=null)
data.release();
data = null;
}
//returns in secs
override function get_length() : Float{
if (disposed) return 0.0;
var pos : cpp.UInt32 = 0;
var res = data.getLength( Cpp.addr(pos), FmodTimeUnit.FTM_MS );
if ( res != FMOD_OK ){
#if debug
//trace("impossible to retrieve sound len");
#end
}
var posF = 1.0 * pos / 1000.0;
return posF;
}
public override function play( ?offsetMs : Float = 0.0, ?nbLoops:Int = 1, ?volume:Float = 1.0) : Channel {
var nativeChan : FmodChannelRef = FaxeRef.playSoundWithHandle( data , false);
var chan = ChannelLowLevel.alloc( nativeChan, name );
#if debug
//trace("[Sound] offset " + offsetMs);
//trace("play " + haxe.Timer.stamp() );
#end
@:privateAccess chan.started = true;
@:privateAccess chan.completed = false;
@:privateAccess chan.disposed = false;
@:privateAccess chan.paused = false;
if( offsetMs != 0.0 ) chan.setPlayCursorMs( offsetMs );
if( volume != 1.0 ) chan.setVolume( volume );
if( nbLoops > 1 ) chan.setNbLoops( nbLoops );
return chan;
}
}
class SoundEvent extends Sound{
public var data : FmodStudioEventDescriptionRef = null;
public function new( data : FmodStudioEventDescriptionRef, ?name:String = null ){
super(name);
this.data = data;
}
public override function dispose(){
super.dispose();
if ( Snd.released ) {
data = null;
return;
}
if ( data != null){
data.releaseAllInstances();
data = null;
}
}
public function getData(){
return data;
}
//returns in secs
override function get_length() : Float{
if (disposed) return 0.0;
var pos : Int = 0;
var res = data.getLength( Cpp.addr(pos) );
if ( res != FMOD_OK ){
//#if !prod
//trace("impossible to retrieve sound len");
//#end
}
var posF = 1.0 * pos / 1000.0;
return posF;
}
public override function play( ?offsetMs : Float = 0.0, ?nbLoops:Int = 1, ?volume:Float = 1.0) : Channel{
var nativeInstance : FmodStudioEventInstanceRef = data.createInstance();
var chan = ChannelEventInstance.alloc( nativeInstance, name );
//#if !prod
//trace("play " + haxe.Timer.stamp() );
//#end
nativeInstance.start();
@:privateAccess chan.started = true;
@:privateAccess chan.completed = false;
@:privateAccess chan.disposed = false;
@:privateAccess chan.paused = false;
if( offsetMs != 0.0 ) chan.setPlayCursorMs( offsetMs );
if( volume != 1.0 ) chan.setVolume( volume );
return chan;
}
}
class Snd {
public static var EMPTY_STRING = "";
public static var PLAYING : hxd.Stack<Snd> = new hxd.Stack();
static var MUTED = false;
static var DISABLED = false;
static var GLOBAL_VOLUME = 1.0;
static var TW = new SndTV();
public var name : String ;
public var pan : Float = 0.0;
public var volume(default,set) : Float = 1.0;
public var curPlay : Null<Channel> = null;
public var bus = otherBus;
public var isDebug = true;
/**
* for when stop is called explicitly
* allows disposal
*/
public var onStop = new hxd.Signal();
public var sound : Sound = null;
var onEnd : Null<Void->Void> = null;
static var fmodSystem : FmodSystemRef = null;
public static var otherBus = new SndBus();
public static var sfxBus = new SndBus();
public static var musicBus = new SndBus();
public function new( snd : Sound, ?name:String ) {
volume = 1;
pan = 0;
sound = snd;
muted = false;
this.name = name==null?EMPTY_STRING:name;
}
public function isLoaded() {
return sound!=null;
}
//does not dispose sound, only instanced
public function stop(){
TW.terminate(this);//prevent reentrancy of fadeStop() stop() not cutting any sound
PLAYING.remove(this);
if ( isPlaying() && !onStop.isTriggering )
onStop.trigger();
if ( curPlay != null){
curPlay.dispose();
curPlay.poolBack();
curPlay = null;
#if !prod
//trace(name+" stopped");
//Lib.showStack();
#end
}
//bus = otherBus;
}
public function dispose(){
//#if !prod
//trace(name+" disposing");
//#end
if ( isPlaying() ){
stop();
}
if ( curPlay != null){
curPlay.dispose();
curPlay.poolBack();
curPlay = null;
//#if !prod
//trace(name+" disposed");
//#end
}
if ( sound != null) {
sound.dispose();
sound = null;
}
onStop.dispose();
onEnd = null;
curPlay = null;
}
/**
*
* @return in ms
*/
public inline function getPlayCursor() : Float {
if ( curPlay == null) return 0.0;
return curPlay.getPlayCursorMs();
}
public function play(?vol:Float, ?pan:Float) : Snd {
if( vol == null ) vol = volume;
if( pan == null ) pan = this.pan;
start(0, vol, 0.0);
return this;
}
/**
* launches the sound, stops previous and rewrite the cur play dropping it into oblivion for the gc
*/
public function start(loops:Int=0, vol:Float=1.0, ?startOffsetMs:Float=0.0) {
if ( DISABLED ) {
//#if debug
//trace("[SND] Disabled");
//#end
return;
}
if ( sound == null ){
//#if debug
//trace("[SND] no inner sound");
//#end
return;
}
if ( isPlaying() ){
//#if !prod
//trace(name+" interrupting ");
//#end
stop();
}
TW.terminate(this);
this.volume = vol;
this.pan = normalizePanning(pan);
PLAYING.push(this);
curPlay = sound.play( startOffsetMs, loops, getRealVolume());
if ( curPlay == null){
//#if !prod
//trace(" play missed?");
//#end
}
else {
//#if !prod
//trace("started");
//#end
}
}
/**
* launches the sound and rewrite the cur play dropping it into oblivion for the gc
*/
public function startNoStop(?loops:Int=0, ?vol:Float=1.0, ?startOffsetMs:Float=0.0) : Null<Channel>{
if ( DISABLED ) {
//#if debug
//trace("[SND] Disabled");
//#end
return null;
}
if ( sound == null ){
//#if debug
//trace("[SND] no inner sound");
//#end
return null;
}
this.volume = vol;
this.pan = normalizePanning(pan);
curPlay = sound.play( startOffsetMs, loops, getRealVolume());
return curPlay;
}
public inline function getDuration() {
return getDurationMs();
}
public inline function getDurationSec() {
return sound.length;
}
/**
* returns in ms
*/
public inline function getDurationMs() {
return sound.length * 1000.0;
}
public static inline
function trunk(v:Float, digit:Int) : Float{
var hl = Math.pow( 10.0 , digit );
return Std.int( v * hl ) / hl;
}
public static function dumpMemory(){
var v0 : Int = 0;
var v1 : Int = 0;
var v2 : Int = 0;
var v0p : cpp.Pointer<Int> = Cpp.addr(v0);
var v1p : cpp.Pointer<Int> = Cpp.addr(v1);
var v2p : cpp.Pointer<Int> = Cpp.addr(v2);
var str = "";
var res = fmodSystem.getSoundRAM( v0p, v1p, v2p );
if ( res != FMOD_OK){
//#if debug
//trace("[SND] cannot fetch snd ram dump ");
//#end
}
inline function f( val :Float) : Float{
return trunk(val, 2);
}
if( v2 > 0 ){
str+="fmod Sound chip RAM all:" + f(v0 / 1024.0) + "KB \t max:" + f(v1 / 1024.0) + "KB \t total: " + f(v2 / 1024.0) + " KB\r\n";
}
v0 = 0;
v1 = 0;
var res = FaxeRef.Memory_GetStats( v0p, v1p, false );
str += "fmod Motherboard chip RAM all:" + f(v0 / 1024.0) + "KB \t max:" + f(v1 / 1024.0) + "KB \t total: " + f(v2 / 1024.0) + " KB";
return str;
}
public function playLoop(?loops = 9999, ?vol:Float=1.0, ?startOffset = 0.0) : Snd {
if( vol==null )
vol = volume;
start(loops, vol, startOffset);
return this;
}
function set_volume(v:Float) {
volume = v;
refresh();
return volume;
}
public function setVolume(v:Float) {
set_volume(v);
}
public inline function getRealPanning() {
return pan;
}
public function setPanning(p:Float) {
pan = p;
refresh();
}
public function onEndOnce(cb:Void->Void) {
onEnd = cb;
}
public function fadePlay(?fadeDuration = 100, ?endVolume:Float=1.0 ) {
var p = play(0.0001);
if ( p == null ){
//trace("nothing ret");
}
else {
if ( p.curPlay == null){
//trace("no curplay wtf?");
}
else
{
//trace("curplay ok");
}
}
tweenVolume(endVolume, fadeDuration);
return p;
}
public function fadePlayLoop(?fadeDuration = 100, ?endVolume:Float=1.0 , ?loops=9999) {
var p = playLoop(loops,0);
tweenVolume(endVolume, fadeDuration);
return p;
}
public function fadeStop( ?fadeDuration = 100 ) {
if ( !isPlaying()){
//#if !prod
//trace("not playing " + name+" winn not unfade");//can cause reentrancy issues
//#end
return null;
}
isDebug = true;
var t = tweenVolume(0, fadeDuration);
t.onEnd = _stop;
return t;
}
public var muted : Bool = false;
public function toggleMute() {
muted = !muted;//todo
setVolume(volume);
}
public function mute() {
muted = true;
setVolume(volume);
}
public function unmute() {
muted = false;
setVolume(volume);
}
public function isPlaying(){
if ( curPlay == null ){
#if !prod
//trace("no curplay");
#end
return false;
}
return curPlay.isPlaying();
}
public static function init(){
#if debug
trace("[Snd] fmod init");
#end
Faxe.fmod_init( 256 );
fmodSystem = FaxeRef.getSystem();
released = false;
}
public static var released = true;
public static function release(){
TW.terminateAll();
for (s in PLAYING)
s.dispose();
PLAYING.hardReset();
released = true;
//trace("releasing fmod");
Faxe.fmod_release();
#if !prod
trace("fmod released");
#end
}
public static function setGlobalVolume(vol:Float) {
GLOBAL_VOLUME = normalizeVolume(vol);
refreshAll();
}
function refresh() {
if ( curPlay != null ) {
var vol = getRealVolume();
//trace("r:"+vol);
curPlay.setVolume( vol );
}
else {
//#if debug
//trace("[Snd] no playin no refresh "+name);
//#end
}
}
public function setPlayCursorSec( pos:Float ) {
if (curPlay != null) {
curPlay.setPlayCursorSec(pos);
}
else {
//#if debug
//trace("setPlayCursorSec/no current instance");
//#end
}
}