Kye's WAV driver question.
TC
Posts: 1,019
Hello all,
This is my first time having the prop play WAV files, and I seam to have hit a brick wall.
I have been trying to find a way to stop the current (playing) WAV file, and play something else. Right now, once the first file is done playing, the next one will start. I don't want that. I don't want to wait until the other file is done playing.
I have tried
I know there is something I am missing, but I just cant see it.
Thanks for any ideas
TC
This is my first time having the prop play WAV files, and I seam to have hit a brick wall.
I have been trying to find a way to stop the current (playing) WAV file, and play something else. Right now, once the first file is done playing, the next one will start. I don't want that. I don't want to wait until the other file is done playing.
I have tried
IF AUDIO_FILE <> NULL AUDIO.OVERRIDESONG(TRUE) AUDIO_PLAY(AUDIO_FILE) PRI AUDIO_PLAY(ACTION) RESULT := \AUDIO.PLAY(@@AUDIO_LIST[ACTION])
I know there is something I am missing, but I just cant see it.
Thanks for any ideas
TC
Comments
It seems that once you are in a play mode, the main audio output loop ignores all human inputs. That may be because the timing is critical. Adding a line of code might throw off the timing and affect the audio quality. But you can try.
This is all theory, I need to look at the actual OBEX object for specifics.
I am monitoring an encoder (detent encoder), and I want it to be with every click of the encoder, the prop will play*a sound. It works a little now, but if you spin the encoder fast, the audio has to catch up. It just does not sound right.
With all the other stuff running, cogs are at a premium. The WAVE player uses 2 just by its self. Then add on the encoder, display, SD card driver, etc...
I would think there is a way to flush the RAM, then reload it with the new data. But I don't know.
I agree, and I would like it to. I have a lite amount of noise that is only there while the driver is on. It can only be heard when there is nothing playing. I am just wondering if there would be any down side of starting and stopping the driver constantly.
EDIT... That did not answer your question. No, the driver does not have to stop a method. Just to immediately stop the current playing file.
What I did is turn off "OVERRIDESONG" right after I requested to play the audio file.
I was so happy I figured out what to do, I compleatly forgot to upload a video. Here you go
-joe
So...
Note... there's not really anyway to call the overrideSong(...) method without running into possible race conditions. There's always a chance that overrideSong(...) could cancel the next song to be played instead of the currently playing song if the currently playing song finishes right before overrideSong(...) is executed. I think the V2 wav player needs to be redesigned to fix this. However, doing so is not on my radar right now.
If you want, you can modify the wavPlayer function in the driver to fix this issue. It's in SPIN. You would need to change the code so that above function executes more or less atomically with respect to the wavPlayer cog. This will require some form of locking I think since the override function bypasses the lockless queue structure.
...
If everything I said sounds hard just keep doing what you are doing and be happy .
I fixed it somewhat, I had to filter it out. The speakers I am using, have a frequency response of 240Hz to 20,000Hz. I first made a high pass filter to remove the low end distortion. I started with a 1kΩ resistor, and found a cap that sounded the best. Then I added a low pass filter to remove the noise (not the best idea, but it works), I kept trying different parts until I found ones that removed the noise, but did not remove to much of the upper end. In turn, I made a band pass filter. What I want to do is, remove the low pass filter, and add a passive notch filter (band stop). That way I can remove the noise, and keep the upper end.
I think I might just do that. And thank you for the approval to modify your code. One thing I do want to add is an "amplifier enable". My amplifier has an enable pin. It would be nice that if there is no audio to be played, it would turn off the amplifier.
What is hard, is a beginner trying to understand your style of coding. I have been getting a good grip on it though. So much so, I have started to code somewhat like you. It is making my code more understandable. For that, I thank you.
The V2 wav player is a bit terse in the coding style. However, it's optimized at least so stray lines of code aren't floating around that would confuse you.
Just modify the wavPlayer function in the driver to add an amplifierEnable signal. Whenever the wavPlayer driver is not idling it's playing something. If you want to be more precise modify the ASM code. But, I don't think you'll need to.
That is exactly one thing I copied.
I don't know PSAM yet. I am still learning. But I will do what you suggested. Thanks
Are you using the V1 or V2 player? Also, which encoder object are you using? I've been playing with the one I wrote and the one Jeff Martin wrote so far.
I am nowhere close to a computer so I can't link the objects. But,
I am using Kye's wave driver V2. And using jonnymac's grey scale encoder.
I can post the objects later next week when I get back home.
No need. I just wondered which ones you were using, though I do want to mention to Kye that neither object can be easily found. I wonder if both could be linked once so I can archive them both on my S///C machine and my Parallax work PC? :nerd:
http://obex.parallax.com/object/329