mirror of
https://github.com/grp/Wii.py.git
synced 2025-06-19 07:15:49 -04:00
added -p argument to pack IMD5 header onto sound.bin
This commit is contained in:
parent
685afc3384
commit
77f6e5b0e4
26
bns.py
26
bns.py
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
from common import *
|
from common import *
|
||||||
|
import Wii
|
||||||
|
|
||||||
class SoundFile:
|
class SoundFile:
|
||||||
def __init__(self, signal, filename, chancnt=2, samplerate=32000):
|
def __init__(self, signal, filename, chancnt=2, samplerate=32000):
|
||||||
@ -612,6 +613,27 @@ def main():
|
|||||||
bns.create_bns(buffer, samplerate, num_chans)
|
bns.create_bns(buffer, samplerate, num_chans)
|
||||||
bns.write(sys.argv[3])
|
bns.write(sys.argv[3])
|
||||||
|
|
||||||
|
elif sys.argv[1] == "-p":
|
||||||
|
f = wave.open(sys.argv[2], 'rb')
|
||||||
|
num_chans = f.getnchannels()
|
||||||
|
samplerate = f.getframerate()
|
||||||
|
assert samplerate >= 32000
|
||||||
|
assert samplerate <= 48000
|
||||||
|
buffer = f.readframes(f.getnframes())
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
bns = BNS()
|
||||||
|
bns.create_bns(buffer, samplerate, num_chans)
|
||||||
|
bns.write(sys.argv[3])
|
||||||
|
|
||||||
|
f2 = open(sys.argv[3], 'rb')
|
||||||
|
tempbuffer = f2.read()
|
||||||
|
f2.close()
|
||||||
|
tempbuffer = Wii.IMD5(tempbuffer).add()
|
||||||
|
f3 = open(sys.argv[3], 'wb')
|
||||||
|
f3.write(tempbuffer)
|
||||||
|
f3.close()
|
||||||
|
|
||||||
elif sys.argv[1] == "-s":
|
elif sys.argv[1] == "-s":
|
||||||
file = open(sys.argv[2], 'rb')
|
file = open(sys.argv[2], 'rb')
|
||||||
if file:
|
if file:
|
||||||
@ -630,6 +652,8 @@ def main():
|
|||||||
print " == OR == "
|
print " == OR == "
|
||||||
print " python bns.py -e <input.wav> <sound.bin> "
|
print " python bns.py -e <input.wav> <sound.bin> "
|
||||||
print " == OR == "
|
print " == OR == "
|
||||||
|
print " python bns.py -p <input.wav> <sound.bin> "
|
||||||
|
print " == OR == "
|
||||||
print " python bns.py -s <sound.bin> "
|
print " python bns.py -s <sound.bin> "
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -645,6 +669,8 @@ if __name__ == "__main__":
|
|||||||
print " == OR == "
|
print " == OR == "
|
||||||
print " python bns.py -e <input.wav> <sound.bin> "
|
print " python bns.py -e <input.wav> <sound.bin> "
|
||||||
print " == OR == "
|
print " == OR == "
|
||||||
|
print " python bns.py -p <input.wav> <sound.bin> "
|
||||||
|
print " == OR == "
|
||||||
print " python bns.py -s <sound.bin> "
|
print " python bns.py -s <sound.bin> "
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user