Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 12:45 04 May 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 : PLAY WAV/TONE......

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9066
Posted: 12:04am 17 Apr 2017
Copy link to clipboard 
Print this post

Hi all, but especially matherp.

The PLAY WAV and PLAY TONE commands are awesome in the MM+, but I do have a request:

- Can the PLAY command be binding such that once configured, these pins are then reserved for playback along the same lines as configuring the LCD would be?

My reasons for asking for this, is that when the PCM starts and stops at the beginning and end of playback of either a WAV file or a sine-wave tone, you get a loud 'Pop!' sound from the speakers. This is no-doubt caused by the I/O pin suddenly going from 0v to 1v PCM - or whatever you have set with PLAY VOLUME. This sudden transition from 0v to whatever causes the amplifier to react badly in the form of the aforementioned pop sound.

If the pins were RESERVED for the playback once the command was issued, then this could be prevented by running the PCM at 50% duty cycle all the time in the background, only varying the PCM as needed for sine-wave output, or WAV playback.

I would hope and expect that this would have the effect of stopping the pop at the start and end of playback, at the expense of you not being able to use those pins for PWM or anything else once you have selected them for the PLAY command.

I would love to hear matherp's thoughts on this, and any other member too.

EDIT: I have found a problem with the PLAY command too. If you have voice prompting in your code as I have, and the system tries to play another prompt when one is still playing, the code stops at the command prompt("Sound output in use"). Is there any way to make the playback start on the NEW wave file, and just ignore playing back the rest of the one that might still be playing in the background?Edited by Grogster 2017-04-18
Smoke makes things work. When the smoke gets out, it stops!
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 03:59am 17 Apr 2017
Copy link to clipboard 
Print this post

  Grogster said  
EDIT: I have found a problem with the PLAY command too. If you have voice prompting in your code as I have, and the system tries to play another prompt when one is still playing, the code stops at the command prompt("Sound output in use"). Is there any way to make the playback start on the NEW wave file, and just ignore playing back the rest of the one that might still be playing in the background?


A status of "PLAY" would be good. MM.PLAY?

PLAY would interrupt current playing sound. If you don't want that interrupt, test for MM.PLAY first?
Micromites and Maximites! - Beginning Maximite
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 04:51am 17 Apr 2017
Copy link to clipboard 
Print this post

I originally implemented the code as you request but it required an additional command. PLAY STOP terminated current playback but left the hardware PWM running. PLAY CLOSE shut off the hardware.

This was simplified when the code was moved to the MM+ so that PLAY STOP also shut down the PWM.

Have you tried a series capacitor between the output and the amplifier? Try 1uF and see if it helps
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9066
Posted: 09:49am 17 Apr 2017
Copy link to clipboard 
Print this post

Yep, tried all sorts of things from caps to pull-up resistors and a cap, but you can't get rid of the loud pop at the start and end of playback.

Here is my current output filtering, which is still popping:





R1 & R2 form a potential-divider to drop the I/O pin voltage down to around 300mV to suit the amp I am using, C1 filters off most of the carrier, and the 10uF AC-couples to the amp.

I have also tried the more standard Maximite filter, and the PICAXE filter too. Nothing stops the pops.

Playback is just fine when it is taking place.
It is just the start and stop pops which are substantial once amplified.

Is there any way we can perhaps go back to the original concept where you need the extra PLAY CLOSE command? Perhaps you could post a version of that HEX here, and I could try this out, and if it solved my problems..... It seems to be that when the PWM starts and stops, this is what is causing the pops, so if we can keep it running, then one would hope that would stop the pops - but prevents you using those pins for anything else I guess.(until you PLAY CLOSE, that is)
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9066
Posted: 09:54am 17 Apr 2017
Copy link to clipboard 
Print this post

  CircuitGizmos said  A status of "PLAY" would be good. MM.PLAY?

PLAY would interrupt current playing sound. If you don't want that interrupt, test for MM.PLAY first?


I was thinking about this one again, and as the current syntax supports an interrupt at the end of playback, you could use that to clear a flag which would do the same thing.

IE:


DO UNTIL PLAY_FLAG=0:LOOP 'If currently playing, wait till finished
PLAY_FLAG=1 'Set flag
PLAY WAV "HELLO.WAV",DONE 'Play wave file, then clear flag


...and the 'DONE' interrupt:


SUB DONE
PLAY_FLAG=0
END SUB


I have not tested that yet, but I will. I expect this SHOULD work.
Smoke makes things work. When the smoke gets out, it stops!
 
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 11:45am 17 Apr 2017
Copy link to clipboard 
Print this post

Can the pins used be made inactive ? Open ?
If you could go from running to open , rather
than high or low it shouldn't pop ....
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 10:47am 18 Apr 2017
Copy link to clipboard 
Print this post

  Grogster said  
Here is my current output filtering, which is still popping:





What happens if you add a 10k pullup resistor to the processor pin in this circuit?


Micromites and Maximites! - Beginning Maximite
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9066
Posted: 03:01pm 18 Apr 2017
Copy link to clipboard 
Print this post

  Grogster said   Yep, tried all sorts of things from caps to pull-up resistors and a cap, but you can't get rid of the loud pop at the start and end of playback.




So, yes, have tried that too hoping that perhaps biasing the pin would help, but it does not.
Smoke makes things work. When the smoke gets out, it stops!
 
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 03:12pm 18 Apr 2017
Copy link to clipboard 
Print this post

I ask once more. Are those pins tri-state ?
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9066
Posted: 03:16pm 18 Apr 2017
Copy link to clipboard 
Print this post

Yes, as far as I know, all I/O pins are. They can be high, low, or high-impedance. I am sure that with respect to this playback thing, they pin starts as high-impedance, and returns to high-impedance when playback finishes.

I will look back over this thread - I don't recall seeing you ask that, but sometimes my brain.....

EDIT: Found your little post. Sorry I did not reply.Edited by Grogster 2017-04-20
Smoke makes things work. When the smoke gets out, it stops!
 
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 04:36pm 18 Apr 2017
Copy link to clipboard 
Print this post

High impedance should not support a pop. (I think) .... :)
I've been through this pop stuff lots (with my music)
IIRC using PWM I pretty much got rid of the pop by
going directly to open. Setting a pin for output or input
it gives a voltage (or 0 V) ......I I R C ???? .....
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 02:01pm 20 Apr 2017
Copy link to clipboard 
Print this post

+1 hitsware...Also maybe the series cap (10uF) would be better straight off the MM output pin...(+ve end to micro) (-ve end feeding the divider)...Also you could bias the output of micro to static mid-point of 1.65V by using say 2 x 100k resistors in series from 3.3 to 0 V...with the junction of the two resistors connected to micro output... this allows you to turn the pin off in MM code, so it would be off at all times when not sending PWM output...this, in combination with the circuit, will allow the MM output to settle and remain at a DC midpoint of 1.65V. (assuming PWM code always modulates [with no DC offset] around a perfect 50:50 duty cycle)

Regards,
PhilEdited by flip 2017-04-22
 
Print this page


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

© JAQ Software 2024