OPL2LPT

Discussion about old sound cards, MIDI devices and sound related accessories.

Re: OPL2LPT

Postby chartreuse » 2017-12-27 @ 01:02

Decided to go with the devil I know and used a minimal implementation of the Reality Adlib Tracker format with no commands and a fixed speed. Because of that I had to write my own song in the tracker, but that's fine since finding Christmas music already tracked has proven to be quite difficult. Forgive my laziness with the instrument choices.

Here's an Epson QX-10 (a CP/M machine) playing Carol of the Bells using the OPL2LPT https://www.youtube.com/watch?v=X7c6bHQUC4k

I'll have to look into the VGM and IMF file types suggested, my only concern being that while they look simple to progress they run at a fairly fast update rate. The QX-10 is only a 4MHz z80, without using the bankswitching I'd also be limited to around a 64kB music file.
User avatar
chartreuse
Newbie
 
Posts: 25
Joined: 2017-12-23 @ 21:01
Location: Alberta, Canada

Re: OPL2LPT

Postby Malvineous » 2017-12-27 @ 02:13

IMF works by sending data as fast as you can then waiting for a certain amount of time before sending more. There are no calculations involved (e.g. converting notes to FNum values), you just output the data and then do nothing for a certain number of ticks. Of all the ways of playing songs on the OPL, IMF probably uses the least CPU power. You'd have no problems on a < 1MHz CPU and since IMF songs are from games that run on XT machines, no long gets even close to 64kB.
User avatar
Malvineous
Oldbie
 
Posts: 549
Joined: 2006-6-11 @ 02:24
Location: Brisbane, Australia

Re: OPL2LPT

Postby pdw » 2017-12-27 @ 11:08

Chartreuse, The origin Adlib Jukebox included a bunch of Christmas songs: http://vgmrips.net/packs/pack/adlib-mus ... m-pc-xt-at
The XMAS and XMASLIB collections here also contain many songs, in ROL format: http://cd.textfiles.com/somuch/smsharew/MUSIC/
pdw
Newbie
 
Posts: 31
Joined: 2016-12-26 @ 18:45

Re: OPL2LPT

Postby chartreuse » 2017-12-28 @ 23:01

Alright, had to give IMF a try. Got the delay loop timing slightly off so it's playing a bit slow, but it works just fine. Feels really weird hearing Commander Keen music being played on a CP/M machine, but that's all thanks to the OPL2LPT. https://youtu.be/AKJ_GgOMLog

It should be easily able to hook up this to any old computer with some form of User port or parallel port, just need 10 output lines. Might make for a neat peripheral for home-brew games on even non-PC systems to support.
User avatar
chartreuse
Newbie
 
Posts: 25
Joined: 2017-12-23 @ 21:01
Location: Alberta, Canada

Re: OPL2LPT

Postby Malvineous » 2017-12-29 @ 02:11

That works really well! The 560Hz timing for Commander Keen means each IMF delay value is one 560th of a second, i.e. an IMF delay value of 560 would cause a one second delay, a value of 280 would delay for half a second, and so on. I see in your video there's a date and time displayed on the screen, so one way of getting the timing right would be to do a simple calibration loop, and count the number of times you can do a no-op loop in one second. Divide this count by 560 and that's your single-tick number, the number of no-op loops you have to run to action an IMF delay of one tick. If you then handle your IMF delay bytes by running a do-nothing loop for the IMF delay value multiplied by the single-tick number, then you should get pretty close to the correct playback speed.

If you want to get really fancy, inspect the OPL data bytes before you send them and do something like this to get a simple display that will change in time with the music, by showing you visually which OPL channels are playing notes. It's pretty low CPU power as well and gives you something nice to look at while you're listening to a song.

Code: Select all
channel_active[0..8] = false // nine channels, 0-8 inclusive

if register & 0xB0 <> 0 then
    channel = register & 0x0F
    if channel < 10 then
        noteon = value & 0x20
        if noteon == 0 then channel_active[channel] = false
        else channel_active[channel] = true
    endif
endif

if delay > 5 then  // no point printing this until all the events have been processed
    for each channel_active, if true print "*" else print "_"
    print "\r" to go back to the start of the line after all channels are printed
    // If your machine is really slow to write to the display, you might need to compensate by reducing the delay a little
    delay = delay - 5
endif
User avatar
Malvineous
Oldbie
 
Posts: 549
Joined: 2006-6-11 @ 02:24
Location: Brisbane, Australia

Re: OPL2LPT

Postby chartreuse » 2017-12-29 @ 02:54

Malvineous wrote:That works really well! The 560Hz timing for Commander Keen means each IMF delay value is one 560th of a second, i.e. an IMF delay value of 560 would cause a one second delay, a value of 280 would delay for half a second, and so on. I see in your video there's a date and time displayed on the screen, so one way of getting the timing right would be to do a simple calibration loop, and count the number of times you can do a no-op loop in one second.

I tried to just do it by cycle counting, but I think I ended up with a mistake in calculation. Plus as you mentioned the QX-10 is displaying the clock on screen, so presumably that's causing an interrupt occasionally (I could disable that clock in the settings). My error is probably just an off by 1 in the DCYCLEVAL.
Code: Select all
;-------------------------------------------------------------------------------
; Delay for 1 IMF cycle
; Cycle length depends on file. Either 280Hz (Duke Nukem II), 560Hz, or 700Hz
;
; 280 -> 4MHz/280Hz -> 14 285.7 cycles
; We'll ignore 280, if we want to do it, then call twice with 560
; 560 -> 4MHz/560Hz ->  7 142.8 cycles
; 700 -> 4MHz/700Hz ->  5 714.3 cycles
;
; DCYCLEVAL calculation
;  (cycles - 4350)/17
; 560 -> (7143-4350)/17 -> 164.3 -> 164
; 700 -> (5714-4350)/17 ->  80.2 ->  80
DCYCLEVAL       EQU     164     ; For 560Hz files
;DCYCLEVAL      EQU     80      ; For 700Hz files

DELAYCYCLE:
#local
        PUSH    BC              ; 11
        LD      B, 0            ; 7
L1:
        NOP                     ; 4
        DJNZ    L1              ; 13/8
        ; 255 * 17 + 15 = 4350
        LD      B, DCYCLEVAL    ; 7
L2:
        NOP                     ; 4
        DJNZ    L2              ; 13/8
        POP     BC              ; 11
        RET
#endlocal


Malvineous wrote:If you want to get really fancy, inspect the OPL data bytes before you send them and do something like this to get a simple display that will change in time with the music, by showing you visually which OPL channels are playing notes. It's pretty low CPU power as well and gives you something nice to look at while you're listening to a song.


Might be a fun thing to add to this project, currently looking into file I/O on CP/M so I'll have it load song files from disk instead of being hard-coded. Have to wonder who my target audience is besides me. Who else out there is running OPL2LPTs hooked up to CP/M machines and not just hooking them up to 486 laptops. :happy:
User avatar
chartreuse
Newbie
 
Posts: 25
Joined: 2017-12-23 @ 21:01
Location: Alberta, Canada

Re: OPL2LPT

Postby Malvineous » 2017-12-29 @ 10:13

If you're not doing it for your own fun then you're doing it for the wrong reasons :) Plus I'm sure at least a few of us without CP/M machines will watch if you put a video up about it. The chances of me getting a CP/M machine are pretty low but I can enjoy it by proxy if there's a video to watch!
User avatar
Malvineous
Oldbie
 
Posts: 549
Joined: 2006-6-11 @ 02:24
Location: Brisbane, Australia

Re: OPL2LPT

Postby Scali » 2017-12-29 @ 10:42

chartreuse wrote:I tried to just do it by cycle counting, but I think I ended up with a mistake in calculation. Plus as you mentioned the QX-10 is displaying the clock on screen, so presumably that's causing an interrupt occasionally (I could disable that clock in the settings).


Well, that would mean there's some kind of interrupt timer in the system. Perhaps you can take over that timer and use it to play the music?
That way you could have the music play in the background, while other stuff is running in the foreground.
Who knows, perhaps you could make the player into some kind of TSR, and then return to the CP/M prompt, so you get background music while you work :)
Scali
l33t
 
Posts: 3394
Joined: 2014-12-13 @ 14:24

Re: OPL2LPT

Postby Paralel » 2017-12-29 @ 15:56

Malvineous wrote:If you're not doing it for your own fun then you're doing it for the wrong reasons :)...

I couldn't agree more strongly with this. This is why we all do this, right? For our own personal satisfaction? Personally, I love making old hardware do new things, even if it requires a new piece to make it do such. Its amazing to think that this kind of stuff actually could have been done before, just no one ever did it. Imagine how many of these would have sold at the time if they had been made? It would have been huge!
Paralel
Newbie
 
Posts: 42
Joined: 2013-4-08 @ 19:49

Re: OPL2LPT

Postby SteveC » 2017-12-30 @ 09:09

Malvineous wrote:If you're not doing it for your own fun then you're doing it for the wrong reasons :) Plus I'm sure at least a few of us without CP/M machines will watch if you put a video up about it. The chances of me getting a CP/M machine are pretty low but I can enjoy it by proxy if there's a video to watch!


+1 This! :)
SteveC
Newbie
 
Posts: 47
Joined: 2017-11-25 @ 22:05
Location: Rayleigh, Essex, UK

Re: OPL2LPT

Postby chartreuse » 2017-12-31 @ 23:22

Paralel wrote:
Malvineous wrote:If you're not doing it for your own fun then you're doing it for the wrong reasons :)...

I couldn't agree more strongly with this. This is why we all do this, right? For our own personal satisfaction?


Oh for sure that's really the only reason I do most of these things, I love playing with and programming on my vintage computers. It's especially fun making an old system do something that it never has done before. Like the QX-10, before the OPL2LPT the only sound option was an internal speaker, which I believe is controlled much like the Apple ]['s.

Scali wrote:Who knows, perhaps you could make the player into some kind of TSR, and then return to the CP/M prompt, so you get background music while you work :)

I think that would probably be a bit of a stretch, though it probably could be done provided the music is small enough. Place the "TSR" in memory below the CCP and modify the top of memory marker in CP/M to remove it. Perhaps even leave most of the code in one of the extra memory banks since most CP/M programs won't touch them.

Paralel wrote:Imagine how many of these would have sold at the time if they had been made? It would have been huge!

It's honestly a surprise that no company attempted this before, someone could have conceivable made this around the time of the Adlib and got some game developers to support it. Could have been a standard, especially for low cost systems.
User avatar
chartreuse
Newbie
 
Posts: 25
Joined: 2017-12-23 @ 21:01
Location: Alberta, Canada

Re: OPL2LPT

Postby Megadisk » 2018-1-01 @ 17:50

What are the chances of having an external parallel to gameport adapter along side the OPL2LPT? Something like this: http://stripesnoop.sourceforge.net/hard ... llel2.html
Megadisk
Member
 
Posts: 100
Joined: 2013-12-19 @ 02:06

Re: OPL2LPT

Postby Paralel » 2018-1-01 @ 20:55

Megadisk wrote:What are the chances of having an external parallel to gameport adapter along side the OPL2LPT? Something like this: http://stripesnoop.sourceforge.net/hard ... llel2.html

I'm not too familiar with the Gameport. Is everything about it standardized, or is it more variable than something like a Parallel port?
Paralel
Newbie
 
Posts: 42
Joined: 2013-4-08 @ 19:49

Re: OPL2LPT

Postby chartreuse » 2018-1-01 @ 21:34

Paralel wrote:I'm not too familiar with the Gameport. Is everything about it standardized, or is it more variable than something like a Parallel port?


It's fairly standardized, at least for older joysticks, I think some of the later 90s ones with more than 4 buttons start doing weird things to get more inputs. There's 2 or 4 digital button inputs (if it can support 2 controllers), and two pairs of analog X, Y inputs (Variable resistors). That adapter linked Only seems to be connecting the 4 buttons inputs from the joystick directly to 4 of the data pins (presumably he parallel port has been set-up in bidirectional mode for input first). It's not meant for connecting actual joysticks to the parallel port, just the face buttons if anything. That circuit is a complete hack as it's relying on the floating button inputs to be above the input threshold on the parallel port, and shorts to ground when pressed. It wouldn't work with the OPL2LPT since the parallel port is in output mode, and the joystick buttons would be shorting various lines of the data-bus to ground.
User avatar
chartreuse
Newbie
 
Posts: 25
Joined: 2017-12-23 @ 21:01
Location: Alberta, Canada

Re: OPL2LPT

Postby dreamblaster » 2018-1-03 @ 10:48

Some news from dkgrizzly :

He patched adlib tracker to support OPL2LPT and 2xOPL2LPT ! :
https://github.com/dkgrizzly/at2lpt/rel ... t-beta-001
AT2LPT Beta Build 001
Patched Adlib Tracker II to support OPL2LPT.
To specify a second OPL2LPT use config option adlib_dual instead of adlib_port.
For adt2play, you can specify which lpt port(s) to use with /lpt1 /lpt2 and/or /lpt3.
The first port mentioned will be the primary, and last port mentioned will be the secondary.

Also he designed a 3d printable case for OPL2LPT : https://www.thingiverse.com/thing:2740939
case.jpg


And he also started to work on a case for CVX4 : https://www.thingiverse.com/thing:2743947

Thanks dkgrizzly !
dreamblaster
Oldbie
 
Posts: 546
Joined: 2015-1-18 @ 19:34
Location: Belgium

Re: OPL2LPT

Postby SteveC » 2018-1-03 @ 11:06

Ooh I'll have to see if I can resurrect my 3d printer (not had a successful print in months - does filament 'go off'?) and print this case out!
SteveC
Newbie
 
Posts: 47
Joined: 2017-11-25 @ 22:05
Location: Rayleigh, Essex, UK

Re: OPL2LPT

Postby Malvineous » 2018-1-03 @ 11:21

chartreuse wrote:That adapter linked Only seems to be connecting the 4 buttons inputs from the joystick directly to 4 of the data pins (presumably he parallel port has been set-up in bidirectional mode for input first). [...] It wouldn't work with the OPL2LPT since the parallel port is in output mode, and the joystick buttons would be shorting various lines of the data-bus to ground.

The parallel port always supported full duplex 8-bit output and 4-bit input from the start. Bi-directional mode and the later enhancements allowed data to come in on the original 8-bit output pins for increased performance, but even the basic port allowed 4-bit input and 8-bit output at the same time. That's how the computer could tell the printer was out of paper mid-print, because one of those four inputs is the 'out of paper' signal. See IEEE 1284 for some details on the various modes.

In theory you could bit-bang joystick data over the 4-bit input while the OPL2LPT was active, but it would use some CPU power so probably wouldn't be ideal. On top of that, if you think it's tricky patching games to send their Adlib data over the LPT, it's at least the same, possibly worse for the joystick!

(EDIT: @SteveC: Yes I believe filament will absorb moisture from the air and then cause printing problems. Google will give you some tips on how to dry it out again.)
User avatar
Malvineous
Oldbie
 
Posts: 549
Joined: 2006-6-11 @ 02:24
Location: Brisbane, Australia

Re: OPL2LPT

Postby matze79 » 2018-1-03 @ 15:29

Hell, YES a case!

i really want a case!

The OPL2TEST works fine on the 286 System.
Need to patch some other Games, need to check for CGA.
matze79
Oldbie
 
Posts: 958
Joined: 2014-12-12 @ 14:25
Location: Germany, Frankonia

Re: OPL2LPT

Postby Jo22 » 2018-1-03 @ 16:15

dreamblaster wrote:Some news from dkgrizzly :

He patched adlib tracker to support OPL2LPT and 2xOPL2LPT ! :
https://github.com/dkgrizzly/at2lpt/rel ... t-beta-001

Wait, I thought Adlib Tracker II was all about OPL3 now and that OPL2 support was
considered deprecated years ago! :shocked:

So does that mean it is based on the older 2.0.x series ?

Q: So, what is Adlib Tracker II, or AT2 for short, anyway?
A: It is an 18-channel FM tracker for the OPL3-chip (or compatible) [..]


Source: http://www.adlibtracker.net/programfaq.php
"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//
User avatar
Jo22
l33t
 
Posts: 2525
Joined: 2009-12-13 @ 07:06
Location: Europe

Re: OPL2LPT

Postby jaZz_KCS » 2018-1-03 @ 20:21

Jo22 wrote:
dreamblaster wrote:Some news from dkgrizzly :

He patched adlib tracker to support OPL2LPT and 2xOPL2LPT ! :
https://github.com/dkgrizzly/at2lpt/rel ... t-beta-001

Wait, I thought Adlib Tracker II was all about OPL3 now and that OPL2 support was
considered deprecated years ago! :shocked:

So does that mean it is based on the older 2.0.x series ?

Q: So, what is Adlib Tracker II, or AT2 for short, anyway?
A: It is an 18-channel FM tracker for the OPL3-chip (or compatible) [..]


Source: http://www.adlibtracker.net/programfaq.php


Well yeah, OPL3 is (amongst other things) stereo. So using 2xOPL2LPTs here does at least make sense, as it can give you stereo when operating two of those at the same time with different data.

But let's face it, it is rare to begin with to be even able to have/use two parallel ports at the same time (all my laptops and desktops only feature one each).
User avatar
jaZz_KCS
Member
 
Posts: 283
Joined: 2017-8-10 @ 11:43

PreviousNext

Return to Sound

Who is online

Users browsing this forum: Scali and 1 guest