Sorry... update on my last post: It's actually OggMusic that plays with far less latency, not ogg sounds. Ogg sounds are unpacked and used the same as wavs internally as far as I know so suffer with the same latency issues.
Using OggMusic is the only way I could get audio to play with low enough latency for a music "Instrument" type app, however other limitations in the OggMusic command set prevented me from taking it further (such as instances being queued and played once a previous sound finishes - no good for an instrument app, and without any instance control, there's no way to code around the problem).
Here's some example code used for testing. It produces a grid of 8 boxes that you can play as keys on a musical instrument. Provide your own samples and play with swapping Ogg for wavs and replacing the PlayMusicOGG commands with PlaySound etc.:
// Project: Kalimba
// Created: 2017-03-24
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Kalimba" )
`SetWindowSize( 1024, 768, 0 )
`SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 100, 100 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 0, 0 )
SetVSync(0)
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetImmersiveMode(1)
`LoadSound(1,"f2-nail-med.wav")
`LoadSoundOGG(1,"f2-nail-med.ogg")
LoadMusicOGG(1,"f2-nail-med.ogg")
LoadMusicOGG(2,"f2-nail-soft.ogg")
LoadMusicOGG(3,"g2-nail-med.ogg")
LoadMusicOGG(4,"g2-nail-soft.ogg")
LoadMusicOGG(5,"bb2-nail-med.ogg")
LoadMusicOGG(6,"bb2-nail-soft.ogg")
loadMusicOGG(7,"d3-nail-med.ogg")
LoadMusicOGG(8,"d3-nail-soft.ogg")
red = MakeColor(255,0,0)
do
` Draw our keys
DrawBox(0,0,100,99,red,red,red,red,0)
DrawBox(0,0,100,50,red,red,red,red,0)
DrawBox(25,0,50,99,red,red,red,red,0)
DrawBox(75,0,100,99,red,red,red,red,0)
touchID = GetRawFirstTouchEvent(1)
while touchID > 0
tapped = GetRawTouchValue( touchID )
if tapped = 0
SetRawTouchValue( touchID, 1 )
`PlayMusicOGG(1)
tx = GetRawTouchCurrentX(touchID)
ty = GetRawTouchCurrentY(touchID)
if tx>=0 and tx<25
if ty>50
PlayMusicOGG(1)
else
playmusicogg(2)
endif
endif
if tx>=25 and tx<50
if ty>50
PlayMusicOGG(3)
else
playmusicogg(4)
endif
endif
if tx>=50 and tx<75
if ty>50
PlayMusicOGG(5)
else
playmusicogg(6)
endif
endif
if tx>=75 and tx<100
if ty>50
PlayMusicOGG(7)
else
playmusicogg(8)
endif
endif
drawbox(tx-4,ty-4,tx+4,ty+4,red,red,red,red,1)
endif
touchID = GetRawNextTouchEvent()
endwhile
Print( str(ScreenFPS(),0) )
Sync()
loop