Flexible wav player with keyboard control
selcuk
Posts: 7
Thanks for all help and very very thanks graham....
I finished flexible wav player with keyboard control..
But code have got a small bug.
When I press a keyboard button, speakers· stop and start again.
how can I mask the starting noise, I need help for this problem...
····
voice rutines listed of below
Thanks for all reply again...
Regards.
Post Edited (selcuk) : 6/12/2008 3:21:54 PM GMT
I finished flexible wav player with keyboard control..
But code have got a small bug.
When I press a keyboard button, speakers· stop and start again.
how can I mask the starting noise, I need help for this problem...
CON _clkmode = xtal1 + pll16x _xinfreq = 6_400_000 '80 MHz OBJ ses : "voice" kb : "Keyboard" PUB Main | i, z, t, sing sing := 1 ses.play_wav(sing) kb.start(26, 27) repeat if(kb.gotkey) handlekey waitcnt(cnt + 6_400_000) PRI HandleKey|key,bShift 'user pressed a key, see what to do key:=kb.getkey bShift:=key&$100 key&=$FF 'strip flags 'turn lower case letters to uppper case case key $61..$7A: key-=$20 case key $41 : ses.play_wav(0) $42 : ses.play_wav(1) $43 : ses.play_wav(2) $44 : ses.play_wav(3) $0D : ses.play_wav(4)
····
voice rutines listed of below
CON buffSize = 100 VAR long parameter1 'to pass @buff1 to ASM long parameter2 'to pass @buff2 to ASM long parameter3 'to pass sample rate to ASM long parameter4 'to pass #samples to ASM long buff1[noparse][[/noparse]buffSize] long buff2[noparse][[/noparse]buffSize] long stack1[noparse][[/noparse]100] byte Header[noparse][[/noparse]44] byte cog,cogasm long stackwav[noparse][[/noparse]80] OBJ SD : "FSRW" PUB play_wav(section): Success stop_wav Success := ( cog := cognew(run(section), @stackwav) + 1) PUB stop_wav if cog cogstop(cog~ - 1) PUB run(section)|n,i,j, SampleRate,Samples sd.pclose i:=sd.mount(0) if (i<>0) repeat 'open file case section 0: i:=sd.popen(string("1.wav"), "r") 1: i:=sd.popen(string("2.wav"), "r") 2: i:=sd.popen(string("3.wav"), "r") 3: i:=sd.popen(string("mtest.wav"), "r") 4: i:=sd.popen(string("ytest.wav"), "r") if (i<>0) repeat i:=sd.pread(@Header, 44) 'read data words to input stereo buffer 'Get sample rate from header SampleRate:=Header[noparse][[/noparse]27]<<24+Header[noparse][[/noparse]26]<<16+Header[noparse][[/noparse]25]<<8+Header[noparse][[/noparse]24] 'get # samples from header Samples:=Header[noparse][[/noparse]43]<<24+Header[noparse][[/noparse]42]<<16+Header[noparse][[/noparse]41]<<8+Header[noparse][[/noparse]40] Samples:=Samples>>2 'Start ASM player in a new cog parameter1:=@buff1[noparse][[/noparse]0] parameter2:=@buff2[noparse][[/noparse]0] parameter3:=CLKFREQ/SampleRate '#clocks between samples'1814'for 44100ksps, 5000 'for 16ksps parameter4:=Samples if cogasm cogstop(cogasm~ -1) cogasm := cognew(@asmwav,@parameter1) + 1 n:=buffSize-1 j:=buffsize*4 'number of bytes to read repeat while (j==buffsize*4) 'repeat until end of file if (buff1[noparse][[/noparse]n]==0) j:=sd.pread(@buff1, buffSize*4) 'read data words to input stereo buffer if (buff2[noparse][[/noparse]n]==0) j:=sd.pread(@buff2, buffSize*4) 'read data words to input stereo buffer sd.pclose DAT ORG 0 ASMWAV 'load input parameters from hub to cog given address in par movd :par,#pData1 mov x,par mov y,#4 'input 4 parameters :par rdlong 0,x add :par,dlsb add x,#4 djnz y,#:par setup 'setup output pins MOV DMaskR,#1 ROL DMaskR,OPinR OR DIRA, DMaskR MOV DMaskL,#1 ROL DMaskL,OPinL OR DIRA, DMaskL 'setup counters OR CountModeR,OPinR MOV CTRA,CountModeR OR CountModeL,OPinL MOV CTRB,CountModeL 'Wait for SPIN to fill table MOV WaitCount, CNT ADD WaitCount,BigWait WAITCNT WaitCount,#0 'setup loop table MOV LoopCount,SizeBuff 'ROR LoopCount,#1 'for stereo MOV pData,pData1 MOV nTable,#1 'setup loop counter MOV WaitCount, CNT ADD WaitCount,dRate MainLoop SUB nSamples,#1 CMP nSamples,#0 wz IF_Z JMP #Done waitcnt WaitCount,dRate RDLONG Right,pData ADD Right,twos 'Going to cheat a bit with the LSBs here... Probably shoud fix this! MOV FRQA,Right ROL Right,#16 '16 LSBs are left channel... MOV FRQB,Right WRLONG Zero,pData ADD pData,#4 'loop DJNZ LoopCount,#MainLoop MOV LoopCount,SizeBuff 'switch table ? CMP nTable,#1 wz IF_Z JMP #SwitchToTable2 SwitchToTable1 MOV nTable,#1 MOV pData,pData1 JMP #MainLoop SwitchToTable2 MOV nTable,#2 MOV pData,pData2 JMP #MainLoop Done 'now stop COGID thisCog COGSTOP thisCog 'Working variables thisCog long 0 x long 0 y long 0 dlsb long 1 << 9 BigWait long 100000 twos long $8000_8000 'Loop parameters nTable long 0 WaitCount long 0 pData long 0 LoopCount long 0 SizeBuff long buffsize 'Left long 0 Right long 0 Zero long 0 'setup parameters DMaskR long 0 'right output mask OPinR long 10 'right channel output pin # DMaskL long 0 'left output mask OPinL long 11 'left channel output pin # CountModeR long %00011000_00000000_00000000_00001010 CountModeL long %00011000_00000000_00000000_00001011 'input parameters pData1 long 0 'Address of first data table pData2 long 0 'Address of second data table dRate long 5000 'clocks between samples nSamples long 2000
Thanks for all reply again...
Regards.
Post Edited (selcuk) : 6/12/2008 3:21:54 PM GMT
Comments
I'm working on the exact same thing, only with Playstation controller as the input device.
Rayman will have to weigh in on the noise issue...
When you post your code use [noparse][[/noparse]code ] and [noparse][[/noparse]/code ] (without the space) above and below your code.
Strange.. Looking again, I can't figure out why the [noparse][[/noparse]code ] didn't take..
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
I'm glad you got it working!!
A good win for your country Turkey last night!!!
Regards,
Coley
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PropGFX Forums - The home of the Hybrid Development System and PropGFX Lite
Yes, Turkey win the last night game, We have got too chance, I hope Our chance will continue all tournament...
Thanks..
Regards...
Hopefully, I'll have time one day to fix that...
you're stopping and starting the cog, which is also turning the pin to input, then pausing while it loads the cog with the program, then sets it back to an output, what you'd be better off doing is in the sample player cog, have it check for a restart variable in hub ram, which then jumps back to the start and reloads the samples header info etc. if you see what I mean.
this should help stop the crackling.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
·
I admit, that I have not looked at the code in detail, or how the wav files are sourced, but if you are not jumping past the 54 Byte header in the wav file, or if the software your wave files are generated from does not chop this header off, then you will hear a distinctive "POP" at the beginning of each wav file if you have a “RAW” wav file player.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
Here's one of my sources:
http://ccrma.stanford.edu/CCRMA/Courses/422/projects/WaveFormat/
It almost sounds like the POP is at the end of the track on test8a.wav
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card? - PropDOS
Need a part? Got spare electronics? - The Electronics Exchange
It's important to make sure that the audio is biased to a midpoint ($7F) at the BEGINNING and at the END of the wav file. This is especially true if you are concatenating several files to form words or phrases from phonetic sound bites. The "POP" could also be caused by this difference in beginning and end bias.
Also, is the Propeller wav player·biased at $7F or does it start from $00 ? It should probably initialize from $7F instead if that is indeed the case.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 6/13/2008 4:57:39 AM GMT
It could be that I picked a poor value (zero) for the flag to indicate a used up buffer... It could be that the beginning of the wav contains this value several times on both channels.
Or, maybe the player is starting before the buffers are filled...
I had the pop issue with Rayman's player which nothing I tried seemed to solve. I recently switched to an external DAC (AD1851) since that's what the final "product" will use. The pop on wave startup, of course, went away *but*... Turning an LED on and off causes a pop on both the "on" and the "off" leading me to wonder if the pop is really a power supply issue, not a digital side issue.
I don't have an oscilloscope (yet) but that's the next thing I intend to look at the problem with.
Maybe it is a power surge...
If somebody solve this problem,please send to form..
Regards..
"The disabling circuit 62 includes a pair of drivers coupled to a reference
potential within the audio codec 14. In operation, the disabling circuit
switches are closed such that the center points of the resistive networks
of the 3-D audio circuitry are coupled to the reference potential. This
prevents cross coupling of the line-in signals via the resistive network
and keeps the left side of the rear output capacitors biased to prevent
turn on popping sounds. In addition, the left and right channel drivers 58
and 60 may be placed in a high impedance state. When multiple channel
operation is indicated, the switches of the disabling circuit are opened
thereby allowing the multiple channel driver 30 to provide surround sound
audio signals to the line-in audio jack 16. I"
Source:
www.patentstorm.us/patents/6885900/description.html
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Aka: CosmicBob
I am particularly interested in a solution for the Propeller Activity Board's DACs.
Thanks,
Brian (BTL24)
Thanks. I will have to investigate your code.
I am using the C library wav_player and activity board and was hoping there may be a hardware fix...like biasing the low pass filter. The propeller output pins are pulled low (through 100K resistor) on activity board...so they aren't floating.
Regards,
Brian (BTL24)
Here's how Jon got it fixed in SPIN, (see post # 3)
http://forums.parallax.com/showthread.php/148280-Prop-sound-quality-question