PageRenderTime 23ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/sfxr/Data.hx

http://github.com/tong/sfxr
Haxe | 58 lines | 39 code | 18 blank | 1 comment | 7 complexity | 53cc2b485ffc8258bb2ef951baef157f MD5 | raw file
 1package sfxr;
 2
 3import flash.utils.ByteArray;
 4import flash.utils.Endian;
 5
 6class Data {
 7	
 8	public static function apply( synth : Synth, file : ByteArray ) {
 9		
10//		synth.deleteCache();
11		
12		file.position = 0;
13		file.endian = Endian.LITTLE_ENDIAN;
14			
15		var version = file.readInt();
16			
17		if( version != 100 && version != 101 && version != 102 )
18			return;
19			
20		synth.waveType = file.readInt();
21		synth.masterVolume = (version == 102) ? file.readFloat() : 0.5;
22			
23		synth.startFrequency = file.readFloat();
24		synth.minFrequency = file.readFloat();
25		synth.slide = file.readFloat();
26		synth.deltaSlide = (version >= 101) ? file.readFloat() : 0.0;
27			
28		synth.squareDuty = file.readFloat();
29		synth.dutySweep = file.readFloat();
30			
31		synth.vibratoDepth = file.readFloat();
32		synth.vibratoSpeed = file.readFloat();
33		var unusedVibratoDelay = file.readFloat();
34			
35		synth.attackTime = file.readFloat();
36		synth.sustainTime = file.readFloat();
37		synth.decayTime = file.readFloat();
38		synth.sustainPunch = file.readFloat();
39			
40		var unusedFilterOn = file.readBoolean();
41		synth.lpFilterResonance = file.readFloat();
42		synth.lpFilterCutoff = file.readFloat();
43		synth.lpFilterCutoffSweep = file.readFloat();
44		synth.hpFilterCutoff = file.readFloat();
45		synth.hpFilterCutoffSweep = file.readFloat();
46			
47		synth.phaserOffset = file.readFloat();
48		synth.phaserSweep = file.readFloat();
49			
50		synth.repeatSpeed = file.readFloat();
51			
52		synth.changeSpeed = (version >= 101) ? file.readFloat() : 0.0;
53		synth.changeAmount = (version >= 101) ? file.readFloat() : 0.0;
54			
55		synth.validate();
56	}
57	
58}