Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93b696f
commit e7e52a4
Showing
32 changed files
with
124 additions
and
4,986 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,17 @@ | ||
package kha; | ||
|
||
import haxe.io.Bytes; | ||
import haxe.io.BytesOutput; | ||
import kha.audio2.ogg.vorbis.Reader; | ||
|
||
/** | ||
* Contains compressed or uncompressed audio data. | ||
*/ | ||
class Sound { | ||
public var compressedData: Bytes; | ||
public var uncompressedData: kha.arrays.Float32Array; | ||
public var length: Float = 0; // in seconds | ||
public var channels: Int = 0; | ||
public var sampleRate: Int = 0; | ||
|
||
public function new(bytes: Bytes) { | ||
var count = Std.int(bytes.length / 4); | ||
uncompressedData = new kha.arrays.Float32Array(count); | ||
for (i in 0...count) { | ||
uncompressedData[i] = bytes.getFloat(i * 4); | ||
} | ||
public var sound_: Dynamic; | ||
|
||
compressedData = null; | ||
public function new(sound_: Dynamic) { | ||
this.sound_ = sound_; | ||
} | ||
|
||
public function uncompress(done: Void->Void): Void { | ||
done(); | ||
} | ||
|
||
public function unload() { | ||
compressedData = null; | ||
uncompressedData = null; | ||
Krom.unloadSound(sound_); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
package kha.audio1; | ||
|
||
typedef Audio = kha.audio2.Audio1; | ||
class Audio { | ||
|
||
public static function play(sound: Sound, loop: Bool = false): kha.audio1.AudioChannel { | ||
var channel = new AudioChannel(sound, loop); | ||
channel.play(); | ||
return channel; | ||
} | ||
|
||
public static function stream(sound: Sound, loop: Bool = false): kha.audio1.AudioChannel { | ||
return play(sound, loop); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,55 @@ | ||
package kha.audio1; | ||
|
||
interface AudioChannel { | ||
public function play(): Void; | ||
public function pause(): Void; | ||
public function stop(): Void; | ||
class AudioChannel { | ||
var sound: kha.Sound; | ||
var loop: Bool; | ||
|
||
public function new(sound: kha.Sound, loop: Bool) { | ||
this.sound = sound; | ||
this.loop = loop; | ||
} | ||
|
||
public function play(): Void { | ||
Krom.playSound(sound.sound_, loop); | ||
} | ||
|
||
public function pause(): Void { | ||
|
||
} | ||
|
||
public function stop(): Void { | ||
Krom.stopSound(sound.sound_); | ||
} | ||
|
||
public var length(get, null): Float; // Seconds | ||
private function get_length(): Float; | ||
|
||
private function get_length(): Float { | ||
return 0.0; | ||
} | ||
|
||
public var position(get, set): Float; // Seconds | ||
private function get_position(): Float; | ||
private function set_position(value: Float): Float; | ||
|
||
private function get_position(): Float { | ||
return 0.0; | ||
} | ||
|
||
private function set_position(value: Float): Float { | ||
return 0.0; | ||
} | ||
|
||
public var volume(get, set): Float; | ||
private function get_volume(): Float; | ||
private function set_volume(value: Float): Float; | ||
|
||
private function get_volume(): Float { | ||
return 1.0; | ||
} | ||
|
||
private function set_volume(value: Float): Float { | ||
return 1.0; | ||
} | ||
|
||
public var finished(get, null): Bool; | ||
private function get_finished(): Bool; | ||
|
||
private function get_finished(): Bool { | ||
return false; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.