Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:08 09 May 2025 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 : PicoMite V6.00.02 release candidates - all versions

     Page 14 of 44    
Author Message
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4853
Posted: 03:09pm 27 Mar 2025
Copy link to clipboard 
Print this post

@Peter,

1/ This version has a very good pause/resume
2/ The dc offset after a play tone x,x,time is gone.

But

<ctrl>-C and PLAY STOP have a horrible sound now. The samples (for a short time) go to 0 volts (so maximum amplitude). You might better have simply muted the audio (write 50% dutycycle in the PWM. (**)




But there is a second side effect that I need to investigate. Petscii Robots does not run anymore. With a message "index out of bounds" while reading a file.
Tonight I may find time to look into this, maybe the file on SD card is damaged. I will try a fresh install of Petscii.

Volhout

(**)= when you keep a certain DC level (PWM) at the output during PAUSE/RESUME a DC coupled amplifier will heat up the speakers during resume (they may even be destroyed). When there is an AC-coupling in the circuit somewhere, the resume will cause a DC jump back to 1.65V. Meaning, you will hear a PLOP AT RESUME. Better mute to 1.65V (50%). May not be the nicest, but in the end most effective and simple solution.


EDIT: a quick check shows that RC7_2 and RC7_3 work fine with petscii robots. It is something in this version that kills it. Maybe the changes in the editor.


.
Edited 2025-03-28 01:15 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10064
Posted: 04:37pm 27 Mar 2025
Copy link to clipboard 
Print this post

  Quote  But there is a second side effect that I need to investigate. Petscii Robots does not run anymore. With a message "index out of bounds" while reading a file.
Tonight I may find time to look into this, maybe the file on SD card is damaged. I will try a fresh install of Petscii.


Don't bother with analysing that, I was playing with some unrelated ideas. I'm only interested in the audio at the moment.
 
JanVolk
Senior Member

Joined: 28/01/2023
Location: Netherlands
Posts: 219
Posted: 08:59pm 27 Mar 2025
Copy link to clipboard 
Print this post

Peter,

Thanks for investigating the edit function.
The tip to temporarily stop using the arrow keys and instead use Pg Up and Pg Dn helped.
And I am correct that I2C has nothing to do with this.
And I saw that if there has been a crash and then the firmware is flashed again, a few lines of the area where the crash occurred appear above the existing code, which is possibly a coincidence?
Also tested with Tera Term and Windows keyboard and mouse settings, but saw no advantage.

Greetings,

Jan.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10064
Posted: 10:41pm 27 Mar 2025
Copy link to clipboard 
Print this post

Here is a RP2040 VGA version that hopefully is better on the audio AND runs Petsci


PicoMiteVGARP2040.zip
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4853
Posted: 11:06am 28 Mar 2025
Copy link to clipboard 
Print this post

@Peter,

RC8 is different, but not okay.

good:
- play pause/resume are fine (same as RC7_4)
- petscii runs, same as several other games.

not good:
- play stop and <ctrl>-C still give the terrible click (have not used the scope, but it sounds the same as RC7_4).
- Kong does not run. It errors at a RESTORE I1B, where I1B is a correct label. Nicely placed at the start of the line with a colon ":" behind it. so "I1B:"
This is so similar to earlier problems with the IF without THEN, where the THEN is clearly at the same line.

I have not tried all programs, but all in all this is not really different from RC7_4, where some program don't run, and sound is changed, but not perfect yet.

I worry most about the programs that fail to run. These are really scary things. I fear (not confirmed) if I change 1 line in the code, a totally other problem can show.
Can't you go back to RC7_2 (or RC7_3) and only make the 1 audio fix for PAUSE/RESUME. Start from there. RC5, RC6, RC7_2 and RC7_3 where running all programs.

Volhout
P.S. I don't have RC7 here, I have it in my work. So I can't figure if RC7 is okay. But the patched version RC&_2, and RC&_3 are.
Edited 2025-03-28 21:09 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10064
Posted: 11:38am 28 Mar 2025
Copy link to clipboard 
Print this post

  Quote  play stop and <ctrl>-C still give the terrible click (have not used the scope, but it sounds the same as RC7_4).


I've checked with the scope and before I could trigger on the pulse - now I can't.
PLAY VOLUME 25,25 PLAY TONE 400,400. Set the scope so it just doesn't trigger on the sine wav. PLAY STOP or ctrl-c and it doesn't trigger. Before I was seeing a spike to GND


This is the code for stop audio

  Quote  void StopAudio(void) {

if(CurrentlyPlaying != P_NOTHING ) {
int ramptime=1000000/PWM_FREQ+2;
if(!(Option.AUDIO_MISO_PIN || Option.audio_i2s_bclk))
{
int ll,l=pwm_hw->slice[AUDIO_SLICE].cc >>16;
int rr,r=pwm_hw->slice[AUDIO_SLICE].cc & 0xFFFF;
int m=((int)(AUDIO_WRAP>>1)*4000)/4096;
l=m-l;
r=m-r;
for(int i=50;i>=0;i--){
ll=m-l*i/50;
rr=m-r*i/50;
pwm_set_both_levels(AUDIO_SLICE,ll,rr);
uSec(ramptime);
}
CurrentlyPlaying = P_STOP;
uSec(ramptime);
setrate(PWM_FREQ);
}
pwm_set_irq0_enabled(AUDIO_SLICE, false);
       ppos=0;
       if(Option.AUDIO_MISO_PIN && (CurrentlyPlaying == P_TONE || CurrentlyPlaying==P_SOUND))CurrentlyPlaying = P_WAVOPEN;
else CurrentlyPlaying = P_NOTHING;
   }
SoundPlay = 0;
}


It reads the current PWM level, and calculates my midpoint 2000/4096, then it ramps between the current level and the midpoint over about 1.2mSec. I don't know with my kit how to view this on the scope other, as above, to confirm it never goes outside of the sine wave envelope and it definitely ends at the desired mid-point.

  Quote  - Kong does not run. It errors at a RESTORE I1B, where I1B is a correct label. Nicely placed at the start of the line with a colon ":" behind it. so "I1B:"

The problem with some of your programs is that you are pushing the available resource to the limits. The IF THEN issue was stack overflowing into heap - nothing to do with the code itself. If you just switched to the RP2350.....
All I do each time is keep trying to find a bit more memory. The easy solution would be to change the heap size from 100Kb to 96Kb but that would definitely break some of your programs.

Please post KONG code and I'll look to see what is causing the problem this time
Edited 2025-03-28 21:52 by matherp
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10064
Posted: 01:39pm 28 Mar 2025
Copy link to clipboard 
Print this post

OK, I dare you to find clicks now

I used a GPIO pin to trigger the scope as either a timed tone ended or immediately after play stop. There were artifacts on the waveform caused by a couple of issue but I think I've stopped them all


PicoMiteVGARP2040.zip

This is a 4000Hz waveform stopped after 600mSec and you can see the nice ramp from the last level back to centre

 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 459
Posted: 04:02pm 28 Mar 2025
Copy link to clipboard 
Print this post

I accept the challenge  

I have reactivated my old VGA board with the PWM output and installed the latest test version. Unfortunately the rp2040 does not support mp3.

So I used my Sultans.wav for it. What can I say? The sound output is perfect! No PLOPPS to produce, not even with [Ctrl]-[c]. Excellent work Peter!  



But the error logic is a bit mixed up.

> play wav "sultans
>
> play pause
> play wav "sultans
Error : Sound output in use for PAUSED
> play resume
Error : Nothing to resume
> play wav "sultans
> play wav "sultans
Error : Sound output in use for MIDI
> play wav "sultans
> play pause
> play wav "sultans
Error : Sound output in use for PAUSED
> play resume
Error : Nothing to resume
>


Matthias

Nachtrag:
> play flac "trick
> play pause
> play pause            <-- stop playing with a little little plop ;-)
Error : Nothing playing



Edited 2025-03-29 02:12 by homa
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10064
Posted: 04:39pm 28 Mar 2025
Copy link to clipboard 
Print this post

Homa and Volhout - thanks for the testing. Hopefully this one gets there.


PicoMiteVGARP2040.zip
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4853
Posted: 04:43pm 28 Mar 2025
Copy link to clipboard 
Print this post

Sorry Homa,

I have to disagree to some point.
The PLAY TONE is perfect.
PLAY WAV and PLAY FLAC are not always. If feels a bit as if the actual audio sample value has impact on the behaviour. Pictures from a different scope.

Sometimes PLAY STOP is almost perfect. Here a single audio sample is wrong. This is almost inaudible.



Sometimes it is perfect. Like the soft return to 50:50 when playing tone.
But sometimes it is not.



Looking at the PLAY TONE (that always works perfect), the correction is always from values <2000 to 2000 (slope upwards). Also if I look at the waveforms Homa send: the correction is always with a rising slope. If you look at the above picture, the value of the signal is >2000, and should ramp downward to 2000 (falling slope). Is that the problem ?

Volhout
PicomiteVGA PETSCII ROBOTS
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 459
Posted: 05:25pm 28 Mar 2025
Copy link to clipboard 
Print this post

  matherp said  Homa and Volhout - thanks for the testing. Hopefully this one gets there.
PicoMiteVGARP2040.zip


You're welcome, thank you for your persistent work.

with the latest version I have the problem in this case,
pause and restart playback too often:
> play flac "trick
> play pause
> play resume
> play pause
> play resume
> play pause
> play resume
> play pause
> play resume
> play pause
> play resume
> play pause
> play resume
> play stop
>


as a result:


double pause and stop is no longer a problem,
but this is still ...
> play flac "trick
> play flac "trick
Error : Sound output in use for FLAC
> play resume
Error : Nothing to resume
> play flac "trick
> play pause
> play flac "trick
Error : Sound output in use for PAUSED
> play resume
Error : Nothing to resume
>

Edited 2025-03-29 03:30 by homa
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10064
Posted: 05:28pm 28 Mar 2025
Copy link to clipboard 
Print this post

  Quote   Is that the problem ?


No I've tested with falling slopes. How are you doing the triggering at the end of playback?

Try this to see if any different.


PicoMiteVGARP2040.zip


Please also post the Kong files I need to test with - thanks
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 459
Posted: 05:41pm 28 Mar 2025
Copy link to clipboard 
Print this post

  matherp said  
  Quote   Is that the problem ?


No I've tested with falling slopes. How are you doing the triggering at the end of playback?

Try this to see if any different.


PicoMiteVGARP2040.zip


Please also post the Kong files I need to test with - thanks


Because of the triggering you probably mean Volhout? I was too lazy for my scope and use audacity and my soundcard in the Yamaha mixer.  


With this version, there is always a plop with this pattern:
> play flac "trick
> play pause
> play stop
>


 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10064
Posted: 05:55pm 28 Mar 2025
Copy link to clipboard 
Print this post

Once more unto the breach, dear friends


PicoMiteVGARP2040.zip


I think I'd got the left and right channels backwards so the slope was on the wrong channel. Of course TONE n,n would show that but TONE n,m gave me the clue
Edited 2025-03-29 04:01 by matherp
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 459
Posted: 06:21pm 28 Mar 2025
Copy link to clipboard 
Print this post

Hi Peter,

the playing stop usually works without a plop when played back with flac. I don't have a pattern for when it fails. But sometimes it works 10 times without error and then 2-3 times with the plop :-(

I need a break and will try again later.

Maybe Volhout will get something out of it.

Matthias
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4853
Posted: 07:25pm 28 Mar 2025
Copy link to clipboard 
Print this post

  matherp said  Once more unto the breach, dear friends


PicoMiteVGARP2040.zip


I think I'd got the left and right channels backwards so the slope was on the wrong channel. Of course TONE n,n would show that but TONE n,m gave me the clue


@Peter,

Last version, playing WAV, 90% good PLAY STOP, 10% still the(a) artefact.
Playing FLAC, have not seen it yet.

This version also plays Kong.
If you are close to release I will carefully test all programs more thoroughly.

Volhout

Triggering: I set the volume so it is between 0.5V and 2.8V max. Then I trigger the scope on 0.3V. These extreme glitches always reach 0V.

The PLAY STOP artefact: I thought it looked like performing a signed operation on an unsigned pwm value.

Volhout
Edited 2025-03-29 05:54 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10064
Posted: 07:41pm 28 Mar 2025
Copy link to clipboard 
Print this post

  Quote  I thought it looked like performing a signed operation on an unsighned pwm value.

No it appears that reading the current PWM output level off pwm_hw->slice[AUDIO_SLICE].cc is unreliable. Sometimes it returns zero. I've changed the algorithm to remember the last value I set rather than trying to read the register and I can't now  break it - but I'm sure you or Homa can  


PicoMiteVGARP2040.zip
Edited 2025-03-29 05:43 by matherp
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4853
Posted: 08:01pm 28 Mar 2025
Copy link to clipboard 
Print this post

What Homa is seeing looks what I described as the risk of keeping the last PWM value, and not returning to 50%.



The "tail" of the audio is the AC coupling of the sound card, compensating the DC of the non-50% dutycycle to zero.

Then at resume, you have a charged AC coupling, that is driven by the new (silent ? around 50%) audio, and the capacitor discharges again, with shown result.




Volhout
PicomiteVGA PETSCII ROBOTS
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 459
Posted: 09:01pm 28 Mar 2025
Copy link to clipboard 
Print this post

I don't want to praise the day before the evening,
but I think you've done it!  

I must have tried play, pause, resume, stop 100 times now with flac and wav at different points and moments. Different pieces of music, with lots of quiet passages. Perfect (enough for my ears!) and I think the best stand ever! From the last ZIP with the time 28-03-2025 19:33.

Now when all the Volhout programs are running and no other problems occur ... wait for HDMI version

Peter, excellent, good job!

Matthias
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 459
Posted: 09:23pm 28 Mar 2025
Copy link to clipboard 
Print this post

Thanks also for enabling pause and resume for MODFILE. I don't want to open a new site, but MODSAMPLE won't work in MODFILE's PAUSE mode. There is no way to change this?

> play modfile "axelf
Playing axel f
> play modsample 1,1
> play pause
> play modsample 1,1
Error : Samples play over MOD file
>


So i have to use a "modified" MOD file, as described by Volhout above, for effects only?

Because my other idea of using the volume doesn't work either, because the sample volume depends on the "general" volume?!
> play volume 25,25
> play modsample 1,1,64


Are the observations and findings I have made correct?
I asked above whether the MODSAMPLE can still be given the grade? If I have understood the whole MOD file concept correctly

Matthias
 
     Page 14 of 44    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025