more QOA testing

pull/48/head
cosmonaut 2023-05-04 00:56:45 -07:00
parent cee218a2dc
commit a869a0e958
2 changed files with 12 additions and 9 deletions

@ -1 +1 @@
Subproject commit 4f696ab0735927872b8227d3f335040c53876e3a
Subproject commit a016259994797f96db2bda75c90b359258e99d09

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Runtime.InteropServices;
@ -13,7 +13,7 @@ namespace MoonWorks.Audio
public override bool AutoUpdate => true;
uint Channels;
uint FrameSize;
uint SamplesPerChannelPerFrame;
uint TotalSamplesPerChannel;
public unsafe static StreamingSoundQoa Load(AudioDevice device, string filePath)
@ -24,7 +24,7 @@ namespace MoonWorks.Audio
fileStream.ReadExactly(fileDataSpan);
fileStream.Close();
var qoaHandle = FAudio.qoa_open((char*) fileDataPtr, fileDataSpan.Length);
var qoaHandle = FAudio.qoa_open((char*) fileDataPtr, (uint) fileDataSpan.Length);
if (qoaHandle == 0)
{
NativeMemory.Free(fileDataPtr);
@ -32,7 +32,8 @@ namespace MoonWorks.Audio
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(
device,
@ -40,7 +41,7 @@ namespace MoonWorks.Audio
qoaHandle,
channels,
sampleRate,
frameSize,
samplesPerChannelPerFrame,
totalSamplesPerChannel
);
}
@ -51,7 +52,7 @@ namespace MoonWorks.Audio
IntPtr qoaHandle,
uint channels,
uint samplesPerSecond,
uint frameSize,
uint samplesPerChannelPerFrame,
uint totalSamplesPerChannel
) : base(
device,
@ -64,8 +65,10 @@ namespace MoonWorks.Audio
FileDataPtr = fileDataPtr;
QoaHandle = qoaHandle;
Channels = channels;
FrameSize = frameSize;
SamplesPerChannelPerFrame = samplesPerChannelPerFrame;
TotalSamplesPerChannel = totalSamplesPerChannel;
BUFFER_SIZE = (int) (samplesPerChannelPerFrame * Channels * sizeof(short));
}
public override void Seek(uint sampleFrame)
@ -81,7 +84,7 @@ namespace MoonWorks.Audio
) {
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 sampleCount = samples * Channels;