Skip to main content

Simple MSD parser (rhythm game format)

Project description

msdparser

Simple MSD parser for Python. MSD is the underlying file format for many rhythm games, most notably both StepMania simfile formats (.sm and .ssc).

Installing

msdparser is available on PyPI. During the current 2.0 beta phase, make sure to pass --pre to pip:

pip install --pre msdparser

Parsing

parse_msd takes a named file or string argument and yields MSDParameter instances:

>>> from msdparser import parse_msd
>>> with open('testdata/Springtime.ssc', 'r', encoding='utf-8') as simfile:
...     for param in parse_msd(file=simfile):
...         if param.key == 'NOTEDATA': break   # stop at the first chart
...         if not param.value: continue        # hide empty values
...         print(param.key, '=', repr(param.value))
...
VERSION = '0.83'
TITLE = 'Springtime'
ARTIST = 'Kommisar'
BANNER = 'springbn.png'
BACKGROUND = 'spring.png'
MUSIC = 'Kommisar - Springtime.mp3'
OFFSET = '-0.090'
SAMPLESTART = '105.760'
SAMPLELENGTH = '15'
SELECTABLE = 'YES'
DISPLAYBPM = '182'
BPMS = '0=181.685'
TIMESIGNATURES = '0=4=4'
TICKCOUNTS = '0=2'
COMBOS = '0=1'
SPEEDS = '0=1=0=0'
SCROLLS = '0=1'
LABELS = '0=Song Start'

Serializing

MSDParameter instances stringify back to MSD. They can be created from a sequence of strings:

>>> from msdparser import MSDParameter
>>> pairs = [('TITLE', 'Springtime'), ('ARTIST', 'Kommisar')]
>>> for key, value in pairs:
...     print(str(MSDParameter(key=key, value=value)))
...
#TITLE:Springtime;
#ARTIST:Kommisar;

Prefer to use MSDParameter over interpolating the key/value pairs between #:; characters yourself. The str() implementation inserts escape sequences where required, preventing generation of invalid MSD.

Documentation

https://msdparser.readthedocs.io/en/latest/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msdparser-2.0.0b3.tar.gz (6.7 kB view hashes)

Uploaded Source

Built Distribution

msdparser-2.0.0b3-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page