add crap broken sound support for vqa
This commit is contained in:
@@ -76,6 +76,33 @@ namespace OpenRA.FileFormats
|
|||||||
return (short)current;
|
return (short)current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] LoadSound(byte[] raw)
|
||||||
|
{
|
||||||
|
var br = new BinaryReader(new MemoryStream(raw));
|
||||||
|
var dataSize = raw.Length;
|
||||||
|
var outputSize = raw.Length * 4;
|
||||||
|
|
||||||
|
var output = new byte[outputSize];
|
||||||
|
var offset = 0;
|
||||||
|
var index = 0;
|
||||||
|
var currentSample = 0;
|
||||||
|
|
||||||
|
while (dataSize-- > 0)
|
||||||
|
{
|
||||||
|
var b = br.ReadByte();
|
||||||
|
|
||||||
|
var t = DecodeSample(b, ref index, ref currentSample);
|
||||||
|
output[offset++] = (byte)t;
|
||||||
|
output[offset++] = (byte)(t >> 8);
|
||||||
|
|
||||||
|
t = DecodeSample((byte)(b >> 4), ref index, ref currentSample);
|
||||||
|
output[offset++] = (byte)t;
|
||||||
|
output[offset++] = (byte)(t >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
public static byte[] LoadSound(Stream s)
|
public static byte[] LoadSound(Stream s)
|
||||||
{
|
{
|
||||||
var br = new BinaryReader(s);
|
var br = new BinaryReader(s);
|
||||||
|
|||||||
@@ -45,7 +45,10 @@ namespace OpenRA.FileFormats
|
|||||||
byte[] origData;
|
byte[] origData;
|
||||||
|
|
||||||
// Final frame output
|
// Final frame output
|
||||||
int[,] frameData;
|
int[,] frameData;
|
||||||
|
byte[] audioData; // audio for this frame: 22050Hz 16bit mono pcm, uncompressed.
|
||||||
|
|
||||||
|
public byte[] AudioData { get { return audioData; } }
|
||||||
|
|
||||||
public VqaReader( Stream stream )
|
public VqaReader( Stream stream )
|
||||||
{
|
{
|
||||||
@@ -124,11 +127,14 @@ namespace OpenRA.FileFormats
|
|||||||
var length = Swap(reader.ReadUInt32());
|
var length = Swap(reader.ReadUInt32());
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case "SND2":
|
case "SND2":
|
||||||
// Don't parse sound (yet); skip data
|
// Don't parse sound (yet); skip data
|
||||||
reader.ReadBytes((int)length);
|
{
|
||||||
break;
|
var rawAudio = reader.ReadBytes((int)length);
|
||||||
|
audioData = AudLoader.LoadSound(rawAudio);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "VQFR":
|
case "VQFR":
|
||||||
DecodeVQFR(reader);
|
DecodeVQFR(reader);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ namespace OpenRA
|
|||||||
return soundEngine.AddSoundSourceFromMemory(data, 1, 16, 22050);
|
return soundEngine.AddSoundSourceFromMemory(data, 1, 16, 22050);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ISoundSource LoadSoundRaw(byte[] rawData)
|
||||||
|
{
|
||||||
|
return soundEngine.AddSoundSourceFromMemory(rawData, 1, 16, 22050);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
soundEngine = new OpenAlSoundEngine();
|
soundEngine = new OpenAlSoundEngine();
|
||||||
@@ -43,6 +48,12 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void SetListenerPosition(float2 position) { soundEngine.SetListenerPosition(position); }
|
public static void SetListenerPosition(float2 position) { soundEngine.SetListenerPosition(position); }
|
||||||
|
|
||||||
|
public static void PlayRaw(byte[] raw)
|
||||||
|
{
|
||||||
|
var sound = LoadSoundRaw(raw);
|
||||||
|
soundEngine.Play2D(sound, false, true, float2.Zero, SoundVolume);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Play(string name)
|
public static void Play(string name)
|
||||||
{
|
{
|
||||||
if (name == "" || name == null)
|
if (name == "" || name == null)
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ namespace OpenRA.Widgets
|
|||||||
if (advanceNext)
|
if (advanceNext)
|
||||||
{
|
{
|
||||||
advanceNext = false;
|
advanceNext = false;
|
||||||
video.AdvanceFrame();
|
video.AdvanceFrame();
|
||||||
|
|
||||||
|
Sound.PlayRaw(video.AudioData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dt > timestep)
|
if (dt > timestep)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#VqaPlayer:
|
VqaPlayer:
|
||||||
# X:WINDOW_RIGHT - 400
|
X:WINDOW_RIGHT - 400
|
||||||
# Y:WINDOW_BOTTOM - 200
|
Y:WINDOW_BOTTOM - 200
|
||||||
# Width:200
|
Width:200
|
||||||
# Height:200
|
Height:200
|
||||||
# Video:aagun.vqa
|
Video:aagun.vqa
|
||||||
Background@MAINMENU_BG:
|
Background@MAINMENU_BG:
|
||||||
Id:MAINMENU_BG
|
Id:MAINMENU_BG
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
|
|||||||
Reference in New Issue
Block a user