From 4b3892e75cd7a48e7aa6ca69b9eb8bab368bcbef Mon Sep 17 00:00:00 2001 From: simondotm Date: Fri, 15 Mar 2019 02:38:28 +0000 Subject: [PATCH] More command line options --- README.md | 18 +++++++++++++++++- ym2sn.py | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2c8ba6d..9bf5024 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,9 @@ This repo contains a script I've created to do the conversion so that you can li ym2sn.py : Convert Atari ST .YM files to SN76489 VGM music files Written in 2019 by Simon Morris, https://github.com/simondotm/ym2149f -usage: ym2sn.py [-h] [-o ] [-v] input +usage: ym2sn.py [-h] [-o ] [-c ] [-s ] [-m ] [-f ] [-a] + [-n] [-v] [-d] + input positional arguments: input YM source file (must be extracted from within the @@ -28,7 +30,21 @@ optional arguments: -h, --help show this help message and exit -o , --output write VGM file (default is '[input].vgm') + -c , --clock Set target SN76489 clock rate to Mhz, default: 4.0 + (4Mhz) + -s , --shift Set target SN76489 LFSR bit to 15 or 16, default: + 15 (BBC Micro) + -m , --samplerate + Set envelope sample rate to Hz (must be divisble + by 50!), default: 50Hz + -f , --filter Filter channels A,B,C,N is a string, eg. -f AB + -a, --attenuation Force SN76489 attentuation mapping (volumes scaled + from YM dB to SN dB) [Experimental] + -n, --noenvelopes Disable envelope simulation -v, --verbose Enable verbose mode + -d, --debug Enable debug mode + + ``` diff --git a/ym2sn.py b/ym2sn.py index ba95cb3..c432774 100644 --- a/ym2sn.py +++ b/ym2sn.py @@ -1348,7 +1348,8 @@ def output_sn_volume(channel, volume): # the TIMER to first position (you must be VERY sound-chip specialist to hear the difference). if ts_on: - print " ERROR: Timer Synth Trigger - Not handled yet" + if ENABLE_DEBUG: + print " ERROR: Timer Synth Trigger - Not handled yet" # timer/sample rate encodings @@ -2174,9 +2175,15 @@ def to_minsec(frames, frames_rate): parser.add_argument("input", help="YM source file (must be extracted from within the original YM file) [input]") parser.add_argument("-o", "--output", metavar="", help="write VGM file (default is '[input].vgm')") - #parser.add_argument("-b", "--buffer", type=int, default=255, metavar="", help="Set decoder buffer size to bytes, default: 255") - #parser.add_argument("-n", "--huffman", help="Enable huffman compression", default=False, action="store_true") + parser.add_argument("-c", "--clock", type=float, default=4.0, metavar="", help="Set target SN76489 clock rate to Mhz, default: 4.0 (4Mhz)") + parser.add_argument("-s", "--shift", type=int, default=15, metavar="", help="Set target SN76489 LFSR bit to 15 or 16, default: 15 (BBC Micro)") + parser.add_argument("-m", "--samplerate", type=int, default=50, metavar="", help="Set envelope sample rate to Hz (must be divisble by 50!), default: 50Hz") + parser.add_argument("-f", "--filter", default='', metavar="", help="Filter channels A,B,C,N is a string, eg. -f AB") + parser.add_argument("-a", "--attenuation", help="Force SN76489 attentuation mapping (volumes scaled from YM dB to SN dB) [Experimental]", default=False, action="store_true") + parser.add_argument("-n", "--noenvelopes", help="Disable envelope simulation", default=False, action="store_true") + #parser.add_argument("-l", "--loops", help="Export two VGM files, one for intro and one for looping section", default=False, action="store_true") parser.add_argument("-v", "--verbose", help="Enable verbose mode", action="store_true") + parser.add_argument("-d", "--debug", help="Enable debug mode", action="store_true") args = parser.parse_args() @@ -2192,6 +2199,27 @@ def to_minsec(frames, frames_rate): # Set options ENABLE_VERBOSE = args.verbose + ENABLE_DEBUG = args.debug + SN_CLOCK = int(args.clock * 1000000.0) + LFSR_BIT = args.shift + ENABLE_ATTENUATION = args.attenuation + + if (args.noenvelopes): + ENABLE_ENVELOPES = False + SIM_ENVELOPES = False + + if (args.samplerate % 50) != 0: + print("ERROR: Envelope sample rate must be divisible by 50Hz.") + sys.exit() + + SAMPLE_RATE = int(args.samplerate / 50) + + if (len(args.filter) != 0): + FILTER_CHANNEL_A = str.find(args.filter, 'A') != -1 + FILTER_CHANNEL_B = str.find(args.filter, 'B') != -1 + FILTER_CHANNEL_C = str.find(args.filter, 'C') != -1 + FILTER_CHANNEL_N = str.find(args.filter, 'N') != -1 + header = None data = None