QL Tinkering

Helpful tips and guides, also new users can ask for help here.
User avatar
Andrew
Aurora
Posts: 904
Joined: Tue Jul 17, 2018 9:10 pm

Re: QL Tinkering

Post by Andrew »

qbits wrote: Sat Aug 17, 2024 9:21 pm Hi Steve,
The two options PAUSE and use of T_ON,T_START,T_COUNT,T_STOP,T_OFF both produce 20ms Delays across a wide range of platforms.
PAUSE is not a reliable method. PAUSE temporarily halts execution for the specified timeout number of frames (there are 50 frames per second in the UK and Europe, 60 frames per second in the US).
So PAUSE will produce 20ms delays in Europe and 16ms delays in US.
Also execution will continue at the end of the timeout OR if a key is pressed. This makes it totally unreliable for most of the games/programs that use the keyboard. That is exactly why I used the Timer in my games.


stevepoole
Aurora
Posts: 797
Joined: Mon Nov 24, 2014 2:03 pm

Re: QL Tinkering

Post by stevepoole »

Hi Folks,

Yes, Andrew, Using PAUSEs makes games or music programming very difficult when you begin.

Somebody recently mentioned that the User Manual states that KEYROW clears the keyboard queue. This is indeed not the case !

Just insert i$=INKEY$ in you innermost loop, before reading from KEYROW().... to clear the Queue satisfactorily. Regards, Steve.


qbits
Trump Card
Posts: 224
Joined: Sun Dec 11, 2016 3:32 pm

Re: QL Tinkering

Post by qbits »

Hi Stev and Andrew,
Where PAUSE and Simon Goodwin’s T_ON, T_START, T_COUNT, T_STOP , T_OFF maybe OK for Games (Andrew I see you use the later in your QStar and Pitman) whereas I think we all agree timing for Musical notes does require a different approach:

Andrew’s use of T_ON etc
515 DEFine PROCedure Delay(ms)
2520 LOCal t
2525 T_START 1
2530 REPeat l
2535 IF T_COUNT(1)>=ms THEN T_STOP 1: EXIT l
2540 END REPeat l
2545 END DEFine Delay

The DATE Timer method as I will refer to It, uses the QL Clock to determine a QL Platforms speed per second to Set a cycle count that can potentially be divided into milliseconds or a PAUSE lower than 20msec. Taking Stev’s suggestion and code we have a Function to return a QL Platforms cycle rate and a Procedure to execute a calculable Time Delay.

Steve Poole’s - QL Clock DATA Timer of fastStave6_bas
5310 DEFine FuNction ajust_timer
5320 LOCal forever,dd,get_set,ticks
5330 forever=1E15: dd=DATE
5340 REPeat get_set: IF dd<>DATE: dd=DATE: EXIT get_set
5350 FOR ticks=1 TO forever: IF dd<>DATE: EXIT ticks
5360 RETurn ticks:
5365 END DEFine

5380 DEFine PROCedure wait(hold)
5390 LOCal dd,delay: IF hold<1: hold=1
5400 dd=DATE: FOR delay=1 TO hold: IF dd<>DATE: END IF
5410 END DEFine

This executes as: BEEP 0,p1,p2,gx,gy:wait dr:BEEP ...where dr (hold) is a product of ticks*required msec Delay.

Thank you both Steve and Andrew this has been a rewarding development in going forward with QLSounds.
I guess the next challenge will be to develop a common QLSound DATA file format.

QBITS
Last edited by qbits on Mon Aug 19, 2024 8:45 am, edited 1 time in total.


stevepoole
Aurora
Posts: 797
Joined: Mon Nov 24, 2014 2:03 pm

Re: QL Tinkering

Post by stevepoole »

Hi Qbits, Andrew and All,

Yes, using the Date timer method, the adjust_timer and wait routines are not only fine for music, but also allow games to be made compatible on ANY platform, as they automatically adjust to processor speed and multitasking overheads.

After developing the method a few years ago, (and posting it on the Forum), much less tearing-out of hair when prototyping programs !

Please feel free to use it as you please. And thanks for posting your codes, Qbits, very promising indeed.... Regards, Steve.

______________________


qbits
Trump Card
Posts: 224
Joined: Sun Dec 11, 2016 3:32 pm

Re: QL Tinkering

Post by qbits »

Hi steve
I’m working the updates to QLSound so thanks for your code.
Checking out keywords and note HOLD seems to be one on my system.

QBITS


stevepoole
Aurora
Posts: 797
Joined: Mon Nov 24, 2014 2:03 pm

Re: QL Tinkering

Post by stevepoole »

Hi Qbits & all,

Here is a rythm box prototype : UNZIP both, LOAD, modify line 30010 for your device, then RUN.... (e)scape, (n)ext, (p)itchswap.

There follows an initialisation sequence. Then on screen, see drumroll number, tempo & time signature.

Under, the beep index code list : (1-5 beeps), (6-9 rests). Below : the note characters.

Rythm definitions are coded on lines 30330 to 30500 and can be added to. (spaces and dots are read ok).

A future version will be more versatile in rendering longer rythms.... Regards, Steve.
font_bytess.zip
(555 Bytes) Downloaded 92 times
Beat3.zip
(2.48 KiB) Downloaded 95 times


qbits
Trump Card
Posts: 224
Joined: Sun Dec 11, 2016 3:32 pm

Re: QL Tinkering

Post by qbits »

Hi All
Back from my break, had a great stayed in an Airb&b, between two weddings.
Big family get together so I’m wacked.

Steve did download your drum beats, played them but not had much of a chance to review the coding.

I’m now trying to finish off the updates and changes to QLSounds.

QBITS


qbits
Trump Card
Posts: 224
Joined: Sun Dec 11, 2016 3:32 pm

Re: QL Tinkering

Post by qbits »

Hi All,
Life has been a bit hectic of late a roller coaster month but some progress on QBITS QLSounds

The pdf updates and code now incorporate the QL Platform Clock TIMER and one or two other changes.

I have also made changes to File Management you can now Edit the whole File Path change Device and add a Sub DIR’s. You are however limited to a max string length of 32 Characters. If you use QBITSConfig the Device can be changed with Up/Down Cursors. If NOT in their place you can Select and Edit up to 16 Device. Drv$(0)=Dev$ the default with Drv$(1 to 15) ie ‘DrvA_’ to ‘DrvO_’ to Select and Edit

In Score Mode I have added key strokes to access the Mini Keyboard directly F2 to F5 represent the Octaves 2 to 5. Press F2 == F5 will take you to the ‘C’ of each respective Octave, add ‘abcdefg’ takes you to a specific Note. Use Shift F2 == F5 + ‘cdfga’ to Select the #Sharp keys. You can PAN the keyboard with CTRL Left/ Right cursors. The Notes are momentarily sounded. Press Shift + Spacebar to continuously sound the note highlighted by the marker [Spacebar to cancel].

QBITS
Attachments
QBMiniKeyboard.jpg
QBMiniKeyboard.jpg (46.36 KiB) Viewed 1576 times
QBITS_QLSounds_bas.zip
(13.57 KiB) Downloaded 48 times
QB06_QLSound_S28.pdf
(1.89 MiB) Downloaded 45 times


User avatar
RalfR
Aurora
Posts: 920
Joined: Fri Jun 15, 2018 8:58 pm

Re: QL Tinkering

Post by RalfR »

Thumbs up, as usual :)


4E75 7000
qbits
Trump Card
Posts: 224
Joined: Sun Dec 11, 2016 3:32 pm

Re: QL Tinkering

Post by qbits »

Hi All,

I have been playing around with the QPC2 AY-3-8910 implementation and Play command….

For the system to deliver a sound output this appears to require a time duration of around 280msec.
If my Metronome is set at 120 with a semiquaver value of 0.25 the beat duration is 150msec.
and I appear to get NO sound output with the QSounds PLAY 1,’o4Cv15’ :Time Delay of 150ms:Sound_AY command settings???.

Working with BEEP and a duration down to 70 msec I still get a sound output.
[Note: An additional factor maybe the inherent latency with how the BEEP function works].

Has anyone a resolution to the problem ???. Maybe I'm missing a set up command to the AY registers, or is this how it is for now.

Steve,
I’ve had a further perusal through your Beat3 code. The q$ strings sort of got that and the timer bit.
Proc which : to set up Random selection of the q$ strings.
Proc drum : main loop with repeats and beats from q$ settings. Then the REST waits and drum action.
Using BEEP attributes, I sort of get the THUD and TAP not sure on the timbre.

However your timing arrangement sent me back to review those in QBITS QLSounds and that has prompted some further changes to the Playback code I’m still working on. I do have a sort of drum Instrumental...

For self amusement I used the QBITS QLFont editor to create some musical notes. QLNotes_fnt header set to 127,64 so it installs in the extended or upper range the QL Font set. Took about five to ten minutes to get the basic note then using the copy, vertical flip of QLFont Editor took another 30-40 minutes to produce the rest.

QLNotes_fnt.jpg
QLNotes_fnt.jpg (21.18 KiB) Viewed 460 times

Nbase=ALCHP(588):LBYTES device_QLNotes_fnt,Nbase: CHAR_USE#ch,0,Nbase [Device ie ‘win1’]


QBITS
Attachments
QLNotes_fnt.zip
(374 Bytes) Downloaded 7 times


Post Reply