Skip to content

Commit

Permalink
More command line options
Browse files Browse the repository at this point in the history
  • Loading branch information
simondotm committed Mar 15, 2019
1 parent 9cc000f commit 4b3892e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <output>] [-v] input
usage: ym2sn.py [-h] [-o <output>] [-c <n>] [-s <n>] [-m <n>] [-f <s>] [-a]
[-n] [-v] [-d]
input
positional arguments:
input YM source file (must be extracted from within the
Expand All @@ -28,7 +30,21 @@ optional arguments:
-h, --help show this help message and exit
-o <output>, --output <output>
write VGM file <output> (default is '[input].vgm')
-c <n>, --clock <n> Set target SN76489 clock rate to <n> Mhz, default: 4.0
(4Mhz)
-s <n>, --shift <n> Set target SN76489 LFSR bit to <n> 15 or 16, default:
15 (BBC Micro)
-m <n>, --samplerate <n>
Set envelope sample rate to <n> Hz (must be divisble
by 50!), default: 50Hz
-f <s>, --filter <s> Filter channels A,B,C,N <s> 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
```

Expand Down
34 changes: 31 additions & 3 deletions ym2sn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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="<output>", help="write VGM file <output> (default is '[input].vgm')")
#parser.add_argument("-b", "--buffer", type=int, default=255, metavar="<n>", help="Set decoder buffer size to <n> 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="<n>", help="Set target SN76489 clock rate to <n> Mhz, default: 4.0 (4Mhz)")
parser.add_argument("-s", "--shift", type=int, default=15, metavar="<n>", help="Set target SN76489 LFSR bit to <n> 15 or 16, default: 15 (BBC Micro)")
parser.add_argument("-m", "--samplerate", type=int, default=50, metavar="<n>", help="Set envelope sample rate to <n> Hz (must be divisble by 50!), default: 50Hz")
parser.add_argument("-f", "--filter", default='', metavar="<s>", help="Filter channels A,B,C,N <s> 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()


Expand All @@ -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
Expand Down

0 comments on commit 4b3892e

Please sign in to comment.