Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
Amnesie Guru Joined: 30/06/2020 Location: GermanyPosts: 692
Posted: 10:19am 07 Oct 2023
Copy link to clipboard
Print this post
Hello again,
I am searching for some kind of "info" whether it is possible to detect if the "play wav" (or any other audio output) is still playing.
Reason for that is obvious: everytime I do something like:
Play wav "myFile"
I have to know exactly how long this will take before I can retrigger this event. Otherwise I get ERRORs because it is still playing. To solve this I can:
Pause
play with
If Timer...
or even deactivate ERRORs via
ON ERROR
(yes this is an awful way! I don't use this!)
IDEA for a possible solution: ------ In my other Arduino / Atmega328p projects I used an external player with an SD card which indicated the "still playing" state via an LED, so I just read this led out whether it is still "HIGH", if not: retrigger - done, problem solved.
I guess this could be solved by Peter via internal commands like: Info("audio output") or some kind?
I think this is an really important feature... Or am I blind and this is already possible?
Edit: I am using latest PicoMite beta. And ...Wouldn't it make more sense to start all over again if an already "playing wav" is executed (again), before it is finished, instead of throwing an error and stopping the whole program?
SORRY! Found it in the manual, just need to try it: "...interrupt is optional and is the name of a subroutine which will be called when the file has finished playing."
Greetings Daniel Edited 2023-10-07 20:40 by Amnesie
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1270
Posted: 10:43am 07 Oct 2023
Copy link to clipboard
Print this post
You can take control by using a Flag..
use subs to controll this makes it easy
'---play a wave sub Wave file$ if not playing then playing=1:PLAY WAV file$ ,nosound end sub '----end playing sub nosound playing=0 end sub
you call it with "Wave nameofyourfile$" the Flag "playing" returns, if there is allready a wave plaing in the Background
you edited it, while I was typing the anwer Edited 2023-10-07 20:48 by Martin H.'no comment
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10379
Posted: 10:46am 07 Oct 2023
Copy link to clipboard
Print this post
mm.info(sound)
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1270
Posted: 10:49am 07 Oct 2023
Copy link to clipboard
Print this post
Thankyou, thats the easyest way 'no comment
Amnesie Guru Joined: 30/06/2020 Location: GermanyPosts: 692
Posted: 11:34am 07 Oct 2023
Copy link to clipboard
Print this post
Thank you Martin & Peter!
@ Peter
This was my first idea, but it isn't mentioned in the whole manual. I've searched for it again. Nothing.
But now I am aware of it
and thank you Martin for posting an example code.
Greetings Daniel Edited 2023-10-07 21:35 by Amnesie