more QOA testing
parent
cee218a2dc
commit
a869a0e958
|
@ -1 +1 @@
|
||||||
Subproject commit 4f696ab0735927872b8227d3f335040c53876e3a
|
Subproject commit a016259994797f96db2bda75c90b359258e99d09
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace MoonWorks.Audio
|
||||||
public override bool AutoUpdate => true;
|
public override bool AutoUpdate => true;
|
||||||
|
|
||||||
uint Channels;
|
uint Channels;
|
||||||
uint FrameSize;
|
uint SamplesPerChannelPerFrame;
|
||||||
uint TotalSamplesPerChannel;
|
uint TotalSamplesPerChannel;
|
||||||
|
|
||||||
public unsafe static StreamingSoundQoa Load(AudioDevice device, string filePath)
|
public unsafe static StreamingSoundQoa Load(AudioDevice device, string filePath)
|
||||||
|
@ -24,7 +24,7 @@ namespace MoonWorks.Audio
|
||||||
fileStream.ReadExactly(fileDataSpan);
|
fileStream.ReadExactly(fileDataSpan);
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
var qoaHandle = FAudio.qoa_open((char*) fileDataPtr, fileDataSpan.Length);
|
var qoaHandle = FAudio.qoa_open((char*) fileDataPtr, (uint) fileDataSpan.Length);
|
||||||
if (qoaHandle == 0)
|
if (qoaHandle == 0)
|
||||||
{
|
{
|
||||||
NativeMemory.Free(fileDataPtr);
|
NativeMemory.Free(fileDataPtr);
|
||||||
|
@ -32,7 +32,8 @@ namespace MoonWorks.Audio
|
||||||
throw new AudioLoadException("Error opening QOA file!");
|
throw new AudioLoadException("Error opening QOA file!");
|
||||||
}
|
}
|
||||||
|
|
||||||
FAudio.qoa_attributes(qoaHandle, out var frameSize, out var channels, out var sampleRate, out var totalSamplesPerChannel);
|
// FIXME: return samples per frame, not the byte size of the frame
|
||||||
|
FAudio.qoa_attributes(qoaHandle, out var channels, out var sampleRate, out var samplesPerChannelPerFrame, out var totalSamplesPerChannel);
|
||||||
|
|
||||||
return new StreamingSoundQoa(
|
return new StreamingSoundQoa(
|
||||||
device,
|
device,
|
||||||
|
@ -40,7 +41,7 @@ namespace MoonWorks.Audio
|
||||||
qoaHandle,
|
qoaHandle,
|
||||||
channels,
|
channels,
|
||||||
sampleRate,
|
sampleRate,
|
||||||
frameSize,
|
samplesPerChannelPerFrame,
|
||||||
totalSamplesPerChannel
|
totalSamplesPerChannel
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,7 @@ namespace MoonWorks.Audio
|
||||||
IntPtr qoaHandle,
|
IntPtr qoaHandle,
|
||||||
uint channels,
|
uint channels,
|
||||||
uint samplesPerSecond,
|
uint samplesPerSecond,
|
||||||
uint frameSize,
|
uint samplesPerChannelPerFrame,
|
||||||
uint totalSamplesPerChannel
|
uint totalSamplesPerChannel
|
||||||
) : base(
|
) : base(
|
||||||
device,
|
device,
|
||||||
|
@ -64,8 +65,10 @@ namespace MoonWorks.Audio
|
||||||
FileDataPtr = fileDataPtr;
|
FileDataPtr = fileDataPtr;
|
||||||
QoaHandle = qoaHandle;
|
QoaHandle = qoaHandle;
|
||||||
Channels = channels;
|
Channels = channels;
|
||||||
FrameSize = frameSize;
|
SamplesPerChannelPerFrame = samplesPerChannelPerFrame;
|
||||||
TotalSamplesPerChannel = totalSamplesPerChannel;
|
TotalSamplesPerChannel = totalSamplesPerChannel;
|
||||||
|
|
||||||
|
BUFFER_SIZE = (int) (samplesPerChannelPerFrame * Channels * sizeof(short));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Seek(uint sampleFrame)
|
public override void Seek(uint sampleFrame)
|
||||||
|
@ -81,7 +84,7 @@ namespace MoonWorks.Audio
|
||||||
) {
|
) {
|
||||||
var lengthInShorts = bufferLengthInBytes / sizeof(short);
|
var lengthInShorts = bufferLengthInBytes / sizeof(short);
|
||||||
|
|
||||||
// NOTE: this function returns samples per channel! */
|
// NOTE: this function returns samples per channel!
|
||||||
var samples = FAudio.qoa_decode_next_frame(QoaHandle, (short*) buffer);
|
var samples = FAudio.qoa_decode_next_frame(QoaHandle, (short*) buffer);
|
||||||
|
|
||||||
var sampleCount = samples * Channels;
|
var sampleCount = samples * Channels;
|
||||||
|
|
Loading…
Reference in New Issue