105 lines
2.8 KiB
Plaintext
105 lines
2.8 KiB
Plaintext
CON
|
|
|
|
_CLKMODE = XTAL1 + PLL16X
|
|
_XINFREQ = 5_000_000
|
|
|
|
|
|
OBJ
|
|
sdfat : "amdflash-fat" 'fatengine
|
|
wav : "admflash-wav" 'sd-wave
|
|
debugx : "pterm" 'debug
|
|
|
|
VAR
|
|
|
|
long leftVolume
|
|
long rightVolume
|
|
long backgroundPlayCog
|
|
long backgroundPlayStack[50]
|
|
|
|
PUB main
|
|
|
|
debugx.start(115200) ' Start des Debug-Terminals
|
|
sdfat.FATEngine
|
|
leftVolume := 50
|
|
rightVolume := 50
|
|
wav.DACEngine(0)
|
|
waitcnt(clkfreq + cnt)
|
|
backgroundPlayCog := -1
|
|
sdfat.mountPartition(0,0)
|
|
|
|
sdw_start
|
|
repeat
|
|
|
|
|
|
CON ''------------------------------------------------- WAV-FUNKTIONEN
|
|
|
|
|
|
PUB sdw_start | len,j,err ''sdw: startet extra cog mit sdwav-engine
|
|
''funktionsgruppe : sdw
|
|
''funktion : wav-datei von sd-card abspielen
|
|
''eingabe : -
|
|
''ausgabe : -
|
|
''busprotokoll : [150][sub.getstr][put.err]
|
|
'' : err - fehlernummer entspr. liste
|
|
|
|
' err := \sdfat.openFile(string("test.wav"), "r") 'datei öffnen
|
|
' if err == 0
|
|
backgroundPlayCog := cognew(programBackgroundPlay, @backgroundPlayStack)
|
|
|
|
PUB sdw_stop ''sdw: stopt cog mit sdwav-engine
|
|
|
|
if(backgroundPlayCog => 0)
|
|
cogstop(backgroundPlayCog)
|
|
wav.stopPlayer
|
|
sdfat.closeFile
|
|
|
|
|
|
PRI programBackgroundPlay | n
|
|
|
|
debugx.str(string("Player gestartet ")) 'debug
|
|
debugx.NewLine
|
|
|
|
dira[24] := 1
|
|
sdfat.openFile(string("test2.wav"), "r")
|
|
|
|
sdfat.setCharacterPosition(22)
|
|
|
|
n := (sdfat.readCharacter | (sdfat.readCharacter << 8))
|
|
debugx.str(string("NumberOfChannels : ")) 'debug
|
|
debugx.dec(n)
|
|
debugx.NewLine
|
|
wav.changeNumberOfChannels(n)
|
|
|
|
n := sdfat.readCharacter | (sdfat.readCharacter << 8) | (sdfat.readCharacter << 16) | (sdfat.readCharacter << 24)
|
|
debugx.str(string("SampleRate : ")) 'debug
|
|
debugx.dec(n)
|
|
debugx.NewLine
|
|
wav.changeSampleRate(n)
|
|
|
|
sdfat.setCharacterPosition(34)
|
|
|
|
n := (sdfat.readCharacter | (sdfat.readCharacter << 8))
|
|
debugx.str(string("BitsPerSample : ")) 'debug
|
|
debugx.dec(n)
|
|
debugx.NewLine
|
|
wav.changeBitsPerSample(n)
|
|
|
|
wav.changeSampleSign(n == 16)
|
|
|
|
wav.changeLeftChannelVolume(leftVolume)
|
|
wav.changeRightChannelVolume(rightVolume)
|
|
|
|
|
|
sdfat.setCharacterPosition(40)
|
|
wav.startPlayer
|
|
|
|
repeat ((sdfat.readCharacter | (sdfat.readCharacter << 8) | (sdfat.readCharacter << 16) | (sdfat.readCharacter << 24)) / 512)
|
|
sdfat.readData(wav.transferData, 512)
|
|
|
|
wav.stopPlayer
|
|
wav.clearData
|
|
|
|
sdfat.closeFile
|
|
cogstop(cogid)
|
|
|