pyresidfp
Emulates the SID sound-chip in software. The C++ emulation code was copied over from
libsidplayfp.
How to install
Requirements for installation from source:
- compiler for ISO C++20
- Python 3.9+ and header files
From PyPI
Install the latest version using
python -m pip install pyresidfp
From cloned git repository
Build from source and install using
python -m pip install .
Example
For the example, NumPy and soundcard python packages
are required. The example is ported from the section Sample Sound Program,
Commodore 64 User's Guide, page 80:
from datetime import timedelta
import numpy as np
import soundcard as sc
from pyresidfp import SoundInterfaceDevice, Voice, ControlBits, Tone
sid = SoundInterfaceDevice()
sid.Filter_Mode_Vol = 15
sid.attack_decay(Voice.ONE, 190)
sid.sustain_release(Voice.ONE, 248)
sid.tone(Voice.ONE, Tone.C4)
sid.control(Voice.ONE, ControlBits.TRIANGLE | ControlBits.GATE)
attack_phase = timedelta(seconds=0.32)
raw_samples = sid.clock(attack_phase)
release_phase = timedelta(seconds=0.3)
sid.control(Voice.ONE, ControlBits.TRIANGLE)
raw_samples.extend(sid.clock(release_phase))
samples = np.array(raw_samples, dtype=np.float32) / 2.0**15
spkr = sc.default_speaker()
spkr.play(data=samples, samplerate=int(sid.sampling_frequency), channels=1)
Credits
We like to thank all contributors of libsidplayfp
, especially:
- Dag Lem: Designed and programmed complete emulation engine.
- Antti S. Lankila: Distortion simulation and calculation of combined waveforms
- Ken Händel: source code conversion to Java
- Leandro Nini: port to c++, merge with reSID 1.0