Welcome, Guest. Please login or register.


Author Topic: Music and Sound ingame on Enterprise (Read 3467 times)

Offline Keith56

  • Beginner
  • *
  • Posts: 28
  • Country: jp
  • Z80FTW!
    • ChibiAkumas
Music and Sound ingame on Enterprise
« on: 2018.February.12. 10:10:41 »
I've recently started researching the Enterprise 128 - with the end goal of converting my CPC game to it.

it seems the Graphics, File and Key input will not be a problem for me, but one thing I'm unclear about is what my options for Sound and Music in game are on the Enterprise

On the CPC I use ArkosTracker (V1 not the new V2) and it's player for all sound and music, and just call it on the interrupts to handle the updating of sound - which is great!

Of course I understand the Enterprise has a different sound chip, and I think it's going to be beyond my understanding (of music and sound concepts at least!) to convert ArkosPlayer to the enterprise sound chip.

I'm wondering if there is a similar opensource player/tracker that I can use in my game for my sound needs? of course it would need to be minimal CPU utilization as my game is graphics heavy!

Any advice would be much appreciated!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter for CPC - http://www.chibiakumas.com
Beginners guide to Mulltiplatform Z80 Assembly Programming...http://www.chibiakumas.com/z80

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: Music and Sound ingame on Enterprise
« Reply #1 on: 2018.February.12. 10:46:11 »
IstvánV wrote a good AY amulator routine for EP, there are problems only when noise and tone sounds on the same channel, and if the music uses high rate envelopes then envelope emulation should be placed into 1KHz interrupt, if you interested in this solution i will search this for you, otherwise we do not have so nice tool like ARKOS tracker on PC Music Box on EP description only in Hungarian, or other possibility to make the music in midi and convert it with midi conv utility to EP, I think the easies way to use AY emulation.

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14722
  • Country: hu
    • http://enterprise.iko.hu/
Re: Music and Sound ingame on Enterprise
« Reply #2 on: 2018.February.12. 10:52:34 »
The Dave similar to the AY, but not same. CPC and Spectrum 128 conversions usualy using AY conversion routine injected to the player code, which is converting AY register writes to Dave. IstvanV made the best conversion routine.
Because the Dave can't made all thing what the AY can, some musics are good some not too good :oops: And at the other side not all Dave capatibilities used.

Currently the best Dave musics: IstvanV made a MIDI conversion utility and player for the converted musics. Then you can use Midi editor on the PC. Also possible set up the ep128emu as midi output device, then you can hear on the fly the edited music with Dave sound. Szipucsu are the master of creating midi musics to the EP.
IstvanV and Szipucsu made a collection of envelopes (Dave instruments) which are really sounds good on Dave!

Offline Keith56

  • Beginner
  • *
  • Posts: 28
  • Country: jp
  • Z80FTW!
    • ChibiAkumas
Re: Music and Sound ingame on Enterprise
« Reply #3 on: 2018.February.12. 12:48:47 »
IstvánV wrote a good AY amulator routine for EP, there are problems only when noise and tone sounds on the same channel, and if the music uses high rate envelopes then envelope emulation should be placed into 1KHz interrupt, if you interested in this solution i will search this for you

If you could let me know some links to this - I'll give it a try, if it turns out not to be good enough I'll try something else, but I'd be interested to give it a go!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter for CPC - http://www.chibiakumas.com
Beginners guide to Mulltiplatform Z80 Assembly Programming...http://www.chibiakumas.com/z80

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: Music and Sound ingame on Enterprise
« Reply #4 on: 2018.February.12. 14:37:05 »
Source code of Cybernoid loader contains this routine, and some more which can be useful, therefore I did not copied the AY rutin only.

The rutin starts here
"ENABLE_STEREO           equ     1"
envelopeInterrupt is the rutin which has to be inserted into interrupt if the music uses AY envelopes, if it has low rate envelopes then it is enough to call from 50Hz interrupt, if not  then a 1Khz Dave interrupt should be activate also beside of 50Hz video interrupt and this rutin should be called in this interrupt.
ayReset resets the AY emulator to it's initial phase, good to use before new song starts.
ayRegisterRead for reading AY register, in: A register contains number of AY register, out: value in A register
ayRegisterWrite for writing AY register, in: A register contains number of AY register, C is data to be written to AY.
ayRegisterWriteAllI writes all AY register from 0-13, DE contains the AY table
ayRegisterWriteAllD writes all AY register from 13-0, DE contains the AY table
setToneAndNoiseMode by this rutin you can check which mode sounds the best if there is sound and noise on the same channel in the music.

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: Music and Sound ingame on Enterprise
« Reply #5 on: 2018.February.12. 15:21:22 »
Source code of Cybernoid loader contains this routine, and some more which can be useful, therefore I did not copied the AY rutin only.

The version of the routine in Cybernoid is a bit old, I also recommend checking other CPC ports like Boulder Dash (bouldash.s).

Offline szipucsu

  • Global Moderator
  • EP addict
  • *
  • Posts: 9898
  • Country: hu
    • Támogató Támogató
    • Webnyelv.hu - Tanuljunk nyelveket!
Re: Music and Sound ingame on Enterprise
« Reply #6 on: 2018.February.12. 17:35:28 »
I suggest using midiplay and midiconv to create Enterprise music. You have to create the song in midi format first, then convert it into Enterprise format. However converting songs from the CPC is different.
100 SOUND SOURCE 2,STYLE 128,PITCH 25.2,SYNC 1
110 SOUND PITCH 25,SYNC 1
120 ! Videos

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: Music and Sound ingame on Enterprise
« Reply #7 on: 2018.February.12. 18:11:28 »
or other possibility to make the music in midi and convert it with midi conv utility to EP, I think the easies way to use AY emulation.

It depends on whether the goal is to compose new music specifically for the Enterprise, or to convert existing music from the CPC. For the latter, AY emulation is the easiest. Creating new music on the CPC first with familiar tools and then converting it is also a good approach, although the AY emulation routines have some limitations.

Composing native DAVE music takes full advantage of the capabilities of the chip, but there is some learning curve. For tips on how to make the best use of the various effects, it is best to ask Szipucsu. There is also a "davetest" program in the downloads for quick experimenting. The tools available for creating EP music are somewhat limited, but you can use:

- BASIC programs, these are easy to write for simple tunes, but become inconvenient when editing more complex polyphonic music
- a MIDI sequencer on PC combined with midiplay and midiconv, the advantage is being able to edit music interactively with full featured PC software, even use a keyboard if you have one, however, it requires more work to set everything up at first
- native editors, the only one I know is Music Box, unlike the above options, this has a player routine for efficient playback in assembly programs

BASIC or MIDI music is expensive to play in its original form. Therefore, games using it like Exorcist and Xorgame play a DAVE register dump of the tune (which midiconv can create with the -render option) that is stored in a compressed format. This method has some limitations, but it can work reasonably well. For both games, the converter program and player routine are available with the source code, the version in Exorcist is newer and more efficient.

Offline Keith56

  • Beginner
  • *
  • Posts: 28
  • Country: jp
  • Z80FTW!
    • ChibiAkumas
Re: Music and Sound ingame on Enterprise
« Reply #8 on: 2018.February.24. 02:32:13 »
Thanks for all the help and advice, I tried the source from Cybernoid and Boulderdash, but they use ASM commands & tricks that winape couldn't compile, and it was too dificult for me to rewrite.

I ended up using the emulator from the source source of the new SYMAMP (it looks like someone did the rewrite for me - as this compiles fine in winape) and got ArkosPlayer working on enterprise - I though I'd post this info here, in case anyone else has the same problem

The thread where the source I used  is linked is below:
https://enterpriseforever.com/programming/symbos-106/msg66052/#msg66052
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter for CPC - http://www.chibiakumas.com
Beginners guide to Mulltiplatform Z80 Assembly Programming...http://www.chibiakumas.com/z80

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: Music and Sound ingame on Enterprise
« Reply #9 on: 2018.February.24. 09:05:26 »
I ended up using the emulator from the source source of the new SYMAMP (it looks like someone did the rewrite for me - as this compiles fine in winape) and got ArkosPlayer working on enterprise - I though I'd post this info here, in case anyone else has the same problem
It was me :)
I made the modifications in SJASM, but at the end I recognized that relabelling addresses are missing from the end of SYMAMP, Prodatron helped me that Winape can produce that address list, this is the reason :)
Please inform me if you need to convert any SJASM, I will try to do that.

Offline Keith56

  • Beginner
  • *
  • Posts: 28
  • Country: jp
  • Z80FTW!
    • ChibiAkumas
Re: Music and Sound ingame on Enterprise
« Reply #10 on: 2018.February.24. 09:36:00 »
Well thankyou! I really didn't fancy my chances of trying to convert such a tricky bit of code! - fortunately I don't think I'll need to convert anything else.

I'll make sure to give credit where due assuming I end up using it!

Oh, one change I had to make, I changed the 'align 16' to 'align 256' - I assume this wasn't needed because of the layout of the original - but the sample I was writing was jumping to a bad address - a smaller align may also work (align 32 seems ok on my test), I've not properly looked at the code to work out the problem yet
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter for CPC - http://www.chibiakumas.com
Beginners guide to Mulltiplatform Z80 Assembly Programming...http://www.chibiakumas.com/z80

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: Music and Sound ingame on Enterprise
« Reply #11 on: 2018.February.24. 12:42:20 »
I did not make the code itself, it was done by Istvanv, I just modified for Symamp in Winape :)
I think if you set ayTablesBegin to 256 boundary then the modified code should work, my modification use it also, it was not directly aligned to 256 boundary, after translation it went there.

The following part is responsible for building the code based on the start address, in my modification ayTablesBegin appeared on address xx00h, but if ayTablesBegin appears on xx20h(xx60h,xxa0h,xxe0h), xx30h(xx70h,xxb0h,xxf0h),xx10h(xx50h,xx90h,xxd0h) the tables are built differently. If you know the exact place of the AY emulation then I can change it for you.

Code: [Select]
    if ($ & 0030h) = 0020h
        block 16, 00
    endif

ayTablesBegin:

    if (ayTablesBegin & 0030h) = 0000h
        ayVolTableMacro
        ayRegMaskTableMacro
    endif
    if (ayTablesBegin & 0030h) = 0010h
        ayRegMaskTableMacro
    endif
    if (ayTablesBegin & 0030h) = 0030h
        ayVolTableMacro
        ayRegistersMacro
    endif
        assert  ($ & 000fh) = 0

ayRegWriteTable:

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: Music and Sound ingame on Enterprise
« Reply #12 on: 2018.February.24. 13:32:52 »
I tried to modify the code to work like the SJASM version, but I could not convert the IF statements, do i see well that WINAPE can use predefined Symbols only in IF statements?
If the AY "emulator" code starts on 256 boundary then the output should be ok with this version.

Offline Keith56

  • Beginner
  • *
  • Posts: 28
  • Country: jp
  • Z80FTW!
    • ChibiAkumas
Re: Music and Sound ingame on Enterprise
« Reply #13 on: 2018.February.24. 13:58:03 »
Don't worry about it for me, when I use it in my program I will put the aligned code in a fixed location... I will make sure the place it is works fine so it will not cause me a problem - I tend to group my aligned code together so it doesn't waste memory anyway!

I only mentioned it on here in case someone else downloaded it and wondered why it didn't work for them - hoped I could spread a little info!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter for CPC - http://www.chibiakumas.com
Beginners guide to Mulltiplatform Z80 Assembly Programming...http://www.chibiakumas.com/z80

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: Music and Sound ingame on Enterprise
« Reply #14 on: 2018.February.24. 14:18:39 »
Ok :-)
I just turned off my computer, when it came to my mind if you align to 64 instead of aligning to 16 the code could be placed anywhere, i did not test it, but the lot of IF`s are used to save memory if alignment in range of 40h