Wrapper needed for SIDplay2

BlitzMax Forums/BlitzMax Beginners Area/Wrapper needed for SIDplay2

You could do the streaming with maxmod :)

As custom streams aren't documented yet heres a lil example of how to do it... (done in linux, so excuse the tabbing)
Strict 
Framework BRL.GLMax2D 
Import MaxMod.Common

Graphics 800,600,0 

MaxMod_Init()

Type SIDStream Extends MaxMod_Stream

	Function Load:SIDStream(File:Object)
	
		Local This:SIDStream = New SIDStream
		Local channels = 2
		'This.samples 		= NumOfSamples		' size of the stream if known
		This.Sample_Rate 	= 44100						' set sample rate
		'This.Stream_Size	= NumOfSamples*2*channels	' set size of stream in bytes if known
		If channels=1 This.STREAM_FORMAT=AL_FORMAT_MONO16 Else This.STREAM_FORMAT=AL_FORMAT_STEREO16

		Return This
		
	EndFunction

	' this method gets called when the buffer needs filling
	Method FillBuffer(BufferIndex) 
		' example of a Stereo16 routine
		Global count
		Local n1,p
		Local sampleptr:Short Ptr = Short Ptr(bufptr[BufferIndex])	' (note: use a byte ptr if in 8 bit mode)
		For n1=0 Until STREAM_BUFFER_SIZE/4	' do each sample (/4 for stereo16, /2 for mono16)
			sampleptr[p] = Cos(count)*32767			' Feed left channel
			sampleptr[p+1] = Cos(count)*32767	' Feed right channel
			count:+1
			p:+2
		Next
	EndMethod

EndType

Local Music:SIDStream = SIDStream.Load("")

Music.Play()

Local Pitch# = 1
Repeat 

	Cls 
	DrawText "  ESCAPE = Exit",5,5
	DrawText "   SPACE = Play",5,20
	DrawText "       S = Stop",5,35
	DrawText "       P = Pause",5,50
	DrawText " UP/DOWN = Pitch",5,65
	
	DrawText "POSITION = "+Music.Geti(MM_POSITION),5,95
	DrawText "  LENGTH = "+Music.Geti(MM_LENGTH),5,110
	DrawText "   PITCH = "+Pitch,5,125
	DrawText "   HERTZ = "+Music.Geti(MM_SAMPLERATE),5,140

	If KeyHit(KEY_S) 	 Then Music.Stop
	If KeyHit(KEY_SPACE) Then Music.Play
	If KeyHit(KEY_P) 	 Then Music.Pause
	If KeyDown(KEY_UP)	 Then Pitch:+0.001 ; Music.Setf(MM_PITCH, Pitch)
	If KeyDown(KEY_DOWN) Then Pitch:-0.001 ; Music.Setf(MM_PITCH, Pitch)

	Flip True
	
Until KeyDown(KEY_ESCAPE) 
Music.Free
End


(BTW, if you want access to the source code, it can be arranged ;) )