News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_trabitboy

sound queue: can't play more than 4 notes

Started by trabitboy, 14:50, 31 August 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

trabitboy

Hi,
I tried a lot to play music using the firmware but ...
I am still having trouble, and the deadline of retrodev is approaching fast  :picard:

I actually used this page as a base:
Programming:Tutorial - Understanding the fundamentals of BASIC SOUND and the

On first test worked pretty satisfactorily, and with the amstrad manual I could find the value to port small bits of music from the piano, but something seems missing; I can only play a couple of notes, afterwards it does nothing.

I could use a hand, I've been through a lot of resources and although MC_SOUND_CHECK is mentioned, I could not find an example of its use.

My test code so far, you can F9 in winape, and call &4000:

.ffly equ &bd19
.sqe equ &bcaa

org &4000
;run start

;TODO use sound check to feed more sounds
;blocked at 4 right now

.start
;ld hl,sdata
;ld hl,do
;call sqec
;call ffly
;ld hl,no
;call sqe
;call ffly
ld hl,do
call sqe
call ffly
ld hl,no
call sqe
call ffly
ld hl,do
call sqe
call ffly
ld hl,re
call sqe
call ffly
ld hl,mi
call sqe
call ffly
ld hl,no
call sqe
call ffly
ld hl,mi
call sqe
call ffly
ld hl,re
call sqe
call ffly
ld hl,mi
call sqe
call ffly

;ld hl,fa
;call sqe
;call ffly
;ld hl,sol
;call sqe
;call ffly
;ld hl,la
;call sqe
;call ffly
;ld hl,si
;call sqe
;call ffly

ret

;.sdata defb 1,0,0,142,0,0,12,#90,#00
.no defb 1,0,0,239,0,0,0,#10,#00
.do defb 1,0,0,239,0,0,12,#20,#00
.re defb 1,0,0,213,0,0,12,#20,#00
.mi defb 1,0,0,190,0,0,12,#20,#00
.fa defb 1,0,0,179,0,0,12,#20,#00
.sol defb 1,0,0,159,0,0,12,#20,#00
.la defb 1,0,0,142,0,0,12,#20,#00
.si defb 1,0,0,127,0,0,12,#20,#00


;239 do
;225 do#
;213 re
;201 re#
;190 mi
;179 fa
;169 fa#
;159 sol
;150 sol#
;142 la
;134 la#
;127 si

trabitboy

a compulsive google search gave me that:
http://www.cpcwiki.eu/imgs/e/e1/The_Amstrad_CPC_Firmware_Guide.txt
I will give it another try: probably my duration is wrong and slots are not freed in time.

AMSDOS

Unfortunately i wrote that sound tutorial just to understand the difference between the firmware sound commands from the BASIC stuff to generate Sound fx and not tunes.

Perhaps the best thing to do is check out the Tunegen program from AA June 1990 Type-ins if your coding in assembly. I've written some notes on that page and have posted some code on the forum in the Type-ins thread to generate some different effects based on info from the manual.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

trabitboy

Thank you !
I will try to find it.

Using MC_SOUND_CHECK , I can play a couple more notes then my "agressive" waiting loop resets the emulated cpc ?

I will try to put a frame flyback interrupt that calls mc sound check , then queues a sound if possible .

AMSDOS

The Tune Generator program can be found here. Most of the program is BASIC (to let you compose a tune), but some M/C is generated when the tune is saved (along with the tune data), which isn't very long if you wanted to study what they did. I was able to poke the relevant part for when the tune reaches the end (it was a little bit annoying playing the tune and then it would go straight back to the beginning and play it all over again).


In the original program I noticed 2 Octave Levels were used, I kept the one of those and used information from the Amstrad Manual to use a Lower Octave, which gives the program some range from High to Low notes. I posted the Data for that here.


But it's only a simple Tune Generator, if you were looking for something in BASIC, @Morri Cool Box incorporates BASIC code based on the Sound Queue to produce a Tune.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

trabitboy

I just saw your answer, thanks for the detailed follow up  8)
I will study your detailed write up out of respect !

Actually , I got a simple player to work using interrupt + sound check + sound queue ;
I was wondering if I could add it to your wiki page ?


.ffly equ &bd19c
.sqe equ &bcaa
.schk equ &bcad

kl_new_frame_fly equ &bcd7
mc_sound_register equ &bd34
kl_del_frame_fly equ &bcdd


org &4000
;run start


.start
;set up interrupt player
ld hl,ff_event_block
ld b,&81
ld c,0
ld de,ff_event_routine
call kl_new_frame_fly


ret

.tune_pt defw tune

;;--------------------------------------------------------------------------------------------

ff_event_block:
defs 10

;;--------------------------------------------------------------------------------------------

ff_event_routine:
;;

LD A,(1)
call schk
;keeping only bits 0 to 2
res 3,A
res 4,A
res 5,A
res 6,A
res 7,A

;VIOLENT
cp 0
jp z,no_free_slot

ld hl,(tune_pt)
ld e,(hl)
inc hl
ld d,(hl)

;WIP end check doesn't work for some reason
ld a,d
cp 0
jp z,no_free_slot ; simple test to assess tune finished

push de
pop hl
;ld hl,(hl)
;ld hl,do
call sqe

ld hl,(tune_pt)
inc hl
inc hl
ld (tune_pt),hl

.no_free_slot

;;
ret

;.sdata defb 1,0,0,142,0,0,12,#90,#00
.no defb 1,0,0,239,0,0,0,#20,#00
.do defb 1,0,0,239,0,0,12,#20,#00
.re defb 1,0,0,213,0,0,12,#20,#00
.mi defb 1,0,0,190,0,0,12,#20,#00
.fa defb 1,0,0,179,0,0,12,#20,#00
.sol defb 1,0,0,159,0,0,12,#20,#00
.la defb 1,0,0,142,0,0,12,#20,#00
.si defb 1,0,0,127,0,0,12,#20,#00

.tune
;defw do,re,mi,do,re,mi,do,re,mi,do,re,mi,do,re,mi
defw do,no,do,no,do,no,re,no,mi,no,mi,no,re,no,mi,no,fa,no,sol
defb 0,0 ;end mark

;239 do
;225 do#
;213 re
;201 re#
;190 mi
;179 fa
;169 fa#
;159 sol
;150 sol#
;142 la
;134 la#
;127 si


I now have a nearly complete proof of concept for retrodev !!!

AMSDOS

Quote from: trabitboy on 16:10, 06 September 16Actually , I got a simple player to work using interrupt + sound check + sound queue ;I was wondering if I could add it to your wiki page ?



That looks quite good. Personally I think it could have its own Wiki Page, because there doesn't seem to be a page for setting up an Event Driver style tune using the Firmware. If it went into the Tutorial, people may not look there, it would need Contents, a BASIC example of the code along with the assembly one and some explanation of the code. The tutorial was merely written to take some BASIC SOUND examples and rework them into an Assembly equivalent, eventually I was going to add some ENV and ENT examples and have Assembly code, but have no idea when I'll get around to that.  :(


I can help set up a new page for that Sound Category if you like.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod