XMPPLAY "blitzkrieg.mod"
SUB xmp_free_context
(BYVAL xmp_context%&
) SUB xmp_release_module
(BYVAL xmp_context%&
) SUB xmp_end_player
(BYVAL xmp_context%&
)
'--- the (rudimentary) frame info type ---
TYPE xmp_frame_info
' /* Current frame information */ posi
AS LONG ' /* Current position */ pattern
AS LONG ' /* Current pattern */ row
AS LONG ' /* Current row in pattern */ num_rows
AS LONG ' /* Number of rows in current pattern */ frame
AS LONG ' /* Current frame */ speed
AS LONG ' /* Current replay speed */ bpm
AS LONG ' /* Current bpm */ time
AS LONG ' /* Current module time in ms */ total_time
AS LONG ' /* Estimated replay time in ms*/ frame_time
AS LONG ' /* Frame replay time in us */ 'we don't use the frame buffer, as we play to an
'external buffer using xmp_play_buffer&()
buffer
AS _OFFSET ' /* Pointer to sound buffer */ buffer_size
AS LONG ' /* Used buffer size */ total_size
AS LONG ' /* Total buffer size */ '----------
volume
AS LONG ' /* Current master volume */ loop_count
AS LONG ' /* Loop counter */ virt_channels
AS LONG '/* Number of virtual channels */ virt_used
AS LONG ' /* Used virtual channels */ sequence
AS LONG ' /* Current sequence */ 'the following is not yet detailed, its just a safety
'margin for now to avoid memory protection faults
xmp_channel_info
AS STRING * 8192 '/* Current channel information */ ctx%& = xmp_create_context%&
xerr&
= xmp_load_module&
(ctx%&
, file$
+ CHR$(0)) xerr2&
= xmp_start_player&
(ctx%&
, _SNDRATE, 0) DIM xfi
AS xmp_frame_info
xmp_get_frame_info ctx%&, m.OFFSET
Tim& = xfi.total_time / 1000
buf& = xmp_play_buffer&(ctx%&, Buf.OFFSET, Buf.SIZE, 0)
Time& = LastRec(Buf)
PRINT "lastrec:"; LastRec
(Buf
) SAVESOUND16S Buf, Time&, "swap.wav"
xmp_end_player ctx%&
xmp_release_module ctx%&
xmp_free_context ctx%&
SUB SAVESOUND16S
(arr
AS _MEM, lenght
AS LONG, file
AS STRING) 'speed upgraded version (now much faster), first SINGLE values are recalculated as INTEGERs and THEN writed at once to file. size
AS LONG ' 4 bytes (file size) subchunksize
AS LONG ' 4 bytes (lo / hi), $00000010 for PCM audio format
AS INTEGER ' 2 bytes (0001 = standard PCM, 0101 = IBM mu-law, 0102 = IBM a-law, 0103 = IBM AVC ADPCM) channels
AS INTEGER ' 2 bytes (1 = mono, 2 = stereo) rate
AS LONG ' 4 bytes (sample rate, standard is 44100) ByteRate
AS LONG ' 4 bytes (= sample rate * number of channels * (bits per channel /8)) Block
AS INTEGER ' 2 bytes (block align = number of channels * bits per sample /8) Bits
AS INTEGER ' 2 bytes (bits per sample. 8 = 8, 16 = 16) subchunk2
AS STRING * 4 ' 4 bytes ("data") contains begin audio samples lenght
AS LONG ' 4 bytes Data block size H16.chunk = "RIFF"
H16.size = 44 + lenght 'two channels, it create 16 bit, stereo wav file, one sample use 2 bytes to one channel
H16.fomat = "WAVE"
H16.sub1 = "fmt "
H16.subchunksize = 16
H16.format = 1
H16.channels = 2
H16.rate = 44100
H16.ByteRate = 44100 * 2 * 16 / 8
H16.Block = 4
H16.Bits = 16
H16.subchunk2 = "data"
H16.lenght = lenght
b = a.SIZE - 2
b = b - 2
LastRec = LR