Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:33 27 Nov 2024 Privacy Policy
Jump to

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.

Forum Index : Microcontroller and PC projects : possibility of reading the "play wav" output whether it is playing?

Author Message
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 396
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: Germany
Posts: 1114
Posted: 10:43am 07 Oct 2023
Copy link to clipboard 
Print this post

You can take control by using a Flag..
  Quote  
PLAY WAV file$ [, interrupt]
The WAV file is played in the background. 'interrupt' is optional and is the
name of a subroutine which will be called when the file has finished playing.

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 Kingdom
Posts: 9122
Posted: 10:46am 07 Oct 2023
Copy link to clipboard 
Print this post

mm.info(sound)
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1114
Posted: 10:49am 07 Oct 2023
Copy link to clipboard 
Print this post

  matherp said  mm.info(sound)

Thankyou, thats the easyest way  
'no comment
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 396
Posted: 11:34am 07 Oct 2023
Copy link to clipboard 
Print this post

Thank you Martin & Peter!

@ Peter

  Quote  mm.info(sound)


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
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024