Jump to content
IGNORED

Python bindings for POKEY?


Pokeypy

Recommended Posts

Hi,

 

having had an Atari 800XL in my young years, I like emulation and basically use "atari++" on my Linux-PC. I'm also experimenting with Python/Pygame and recently PySFML. I'd like to create an Atari-like environment for these libraries, so that games that have an Atari 8 bit-look can be written in Python.

PyGame and PySFML can play samples. But emulators like atari++ recreate POKEY with its 4 real-time synthesizer channels. In Atari BASIC, I can do this:

10 SOUND 0, 253, 10, 9

20 SOUND 1, 255, 10, 9

30 FOR I=0 TO 1500:NEXT I[code]

Using the Atari-emulator, this produces chorus POKEY sound on my PC. So I though, what, if there was a Python module for that?

So that I could do this (and other sound related things) from Python, that is from outside the emulator:

[code]#!/usr/bin/python
import pokey_emulator as pokey
import time

def resetPokey():
    pokey.sound(0, 0, 0, 0)
    pokey.sound(1, 0, 0, 0)

pokey.sound(0, 253, 10, 9)
pokey.sound(1, 255, 10, 9)

time.sleep(3)
resetPokey()

Wouldn't that be cool? I don't think, there is such a module yet. And I'm not smart enough to convert the emulator's source code to one. But maybe others are. I think, that would make a really nice project.

 

Cheers

Link to comment
Share on other sites

Unfortunately, a code-tag was set wrong in the last posting, and I can't edit it.

What I'd love to see one day, would be a Python-module, that would let me do this:

#!/usr/bin/python
	 
import pokey_emulator as pokey
import time
	 
def resetPokey():
	pokey.sound(0, 0, 0, 0)
	pokey.sound(1, 0, 0, 0)
	 
pokey.sound(0, 253, 10, 9)
pokey.sound(1, 255, 10, 9)
time.sleep(3)
resetPokey()

Just like that from the Python-script.

Without an instance of a full emulator running in the background.

Edited by Pokeypy
Problems with code-tag.
Link to comment
Share on other sites

Well, all of this seems more complicated than I thought.

 

Looking at the source code of atari++, it seems, the chips of the Atari are emulated separately in classes, and then everything is wired together. In theory, it should be possible to extract just the sound emulation and make for example a library of it. That could then be called from a C++-program, or with Python-bindings also from Python. But it's too difficult for me, one would have to understand the full emulator for that, which I don't.

The question is also, if it's worth it. I'm not sure, if anybody has ever written a good song in Atari BASIC, and from Python it would be as well not as easy to program more than just a few noises. People would probably just prefer using a Tracker program.

 

Actually, If I wanted to get sound from a Python-script, I could just connect it (using the modules "alsaseq" and "alsamidi" on Linux) to multiple full-size soft-synthesizers like ZynAddSubFx or Dexed (DX7). That would take up some CPU. But actually emulating the POKEY also takes more CPU than I expected. I wanted it to be easy and simple (like a "SOUND" command in Atari BASIC), but it seems it takes more CPU and the whole alsa-device anyway, as the emulation seems to create a stream of samples in real-time, that it pipes to the DSP-device. That's quite similar to other softsynths, it's not easier and simpler.

 

Taking a look over to the C64 side of things, there is a library called "reSID", that is integrated into the VICE emulator. It may be possible to compile it as a a stand-alone sound library (which maybe could be used as said above then). There's also a tracker called "Goat Tracker 2" that uses it, and that way provides a tracker for the SID chip (I can compile it on my Linux box, doing a "make clean" and then just a "make"). So for the SID, there would be a tracker and also a library.

And there's also an attempt to create Python bindings called "pyresid", but I couldn't compile it on my machine.

 

So, for my Atari-like game environment in Python it is probably the easiest way, just to sample a bunch of sounds from an emulation, and then use these samples in my game.

 

I still like the idea of accessing a POKEY library from Python directly though.

It would somehow add to a PC to always have a virtual POKEY at your fingertips, like you used to have a real one in BASIC on the Atari.

Edited by Pokeypy
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...