Permalink
Browse files

DEVTOOLS: Multilingual support for quoteSpreadsheetCreator

Versions supported are English, German, French, Italian and Spanish

More work would be required for Russian versions to be supported by the spreadsheet creator.
I don't have access to the Russian version that ScummVM currently supports/in the detection table.
Current implementation could be improved (to do away with all the if clauses for the glyph "exceptions")
but this is not high priority.
  • Loading branch information...
antoniou79 authored and sev- committed Jan 1, 2019
1 parent 6e62a3e commit 234cdf19e5ef1eb6d8baedcd9476fe4354f45368
@@ -59,15 +59,15 @@ def aud_decode_ima_chunk(audioBufferIn, index, sample, cs_chunk):

audioBufferOut = []
#for i in range(0, len(audioBufferIn)):
# print '%d: %d'%(i, int(audioBufferIn[i]))
# print 'Debug:: %d= %d'%(i, int(audioBufferIn[i]))

for sample_index in range (0, cs_chunk):
try:
code = audioBufferIn[sample_index >> 1]
except:
code = 0xa9 # dummy workaround because the c code is accessing an out of bounds index sometimes due to this shift here
#print "cs_chunk %d, sample_index %d, shifted %d, code: %d" % (cs_chunk, sample_index, sample_index >> 1, int(audioBufferIn[sample_index >> 1]))
#print "cs_chunk %s, sample_index %s, shifted %s, code: %s" % \
#print "Debug:: cs_chunk %d, sample_index %d, shifted %d, code= %d" % (cs_chunk, sample_index, sample_index >> 1, int(audioBufferIn[sample_index >> 1]))
#print "Debug:: cs_chunk %s, sample_index %s, shifted %s, code= %s" % \
# (''.join('{:04X}'.format(cs_chunk)), ''.join('{:02X}'.format(sample_index)), ''.join('{:02X}'.format(sample_index >> 1)), ''.join('{:04X}'.format(int(code))))
code = code >> 4 if (sample_index & 1) else code & 0xf
step = aud_ima_step_table[index]
@@ -88,7 +88,7 @@ def aud_decode_ima_chunk(audioBufferIn, index, sample, cs_chunk):
sample = 32767
audioBufferOut.append(ctypes.c_short( sample ).value )
#audioBufferOut.append(sample) # it's not different from above... ctypes.c_short( sample ).value
#print "audio_out[%s]: %s" % (''.join('{:02X}'.format(sample_index)), ''.join('{:02X}'.format(audioBufferOut[sample_index])));
#print "Debug:: audio_out[%s]= %s" % (''.join('{:02X}'.format(sample_index)), ''.join('{:02X}'.format(audioBufferOut[sample_index])));
index += aud_ima_index_adjust_table[code & 7]
if (index < 0):
index = 0
@@ -220,11 +220,11 @@ def decode_chunk(self, audio_in, cs_chunk):

if __name__ == '__main__':
# main()
print "Running %s as main module" % (my_module_name)
print "Debug:: Running %s as main module" % (my_module_name)
decodeInstance = audFileDecode()

else:
#debug
#print "Running %s imported from another module" % (my_module_name)
#print "Debug:: Running %s imported from another module" % (my_module_name)
pass

@@ -82,7 +82,7 @@ def __init__(self):

# std::fstream& fs, AudFileNS::pos_type startAudFilepos, AudFileNS::pos_type endAudFilepos, const std::string& filename
def extract_as_wav(self, audBytesBuff, filename):
print "Saving to wav: " + filename
print "Info:: Saving to wav: " + filename

cvirtualBinaryD = self.decode(audBytesBuff)
# TODO DEBUG REMOVED FOR NOW. TODO RESTORE THIS!!!
@@ -138,10 +138,10 @@ def loadAudFile(self, audBytesBuff, maxLength):
tmpTuple = struct.unpack_from('b', audBytesBuff, offsInAudFile)
self.header().compression = tmpTuple[0]
offsInAudFile += 1
print "samplerate: %d\tsizeIn: %d\tsizeOut: %d\tflags: %d\tcompression: %d" % (self.get_samplerate(), self.header().size_in, self.header().size_out, self.header().flags, self.header().compression)
print "Debug:: Sample rate= %d\tsizeIn= %d\tsizeOut= %d\tflags= %d\tcompression= %d" % (self.get_samplerate(), self.header().size_in, self.header().size_out, self.header().flags, self.header().compression)

if self.get_samplerate() < 8000 or self.get_samplerate() > 48000 or self.header().size_in > (maxLength - SIZE_OF_AUD_HEADER_IN_BYTES ):
print "AUD HEADER SIZE ERROR::2"
print "Error:: Bad AUD Header size::2"
return False
else:
if self.header().compression == 1:
@@ -205,7 +205,7 @@ def get_chunk_header(self, chunkIdx, inAudFileBytesBuffer, inAudFileSize ):
def get_chunk_data(self, inAudFileBytesBuffer, startOffs, sizeToRead):
#fs.read((char*)byteChunkDataPtr, sizeToRead)
outChunkDataLst = []
#print "startOffs %d, sizeToRead %d" % (startOffs, sizeToRead)
#print "Debug:: startOffs %d, sizeToRead %d" % (startOffs, sizeToRead)
for i in range(startOffs, startOffs + sizeToRead):
#outChunkDataLst.append(ctypes.c_char(inAudFileBytesBuffer[i]).value)
#outChunkDataLst.append(ctypes.c_byte(inAudFileBytesBuffer[i]).value)
@@ -221,7 +221,7 @@ def get_chunk_data(self, inAudFileBytesBuffer, startOffs, sizeToRead):
def decode(self, audBytesBuff):
# The * operator unpacks an argument list. It allows you to call a function with the list items as individual arguments.
# binDataOut = struct.pack('i'*len(data), *data)
print "DECODING..."
print "Info:: DECODING..."
# Cvirtual_binary d;
binaryDataOutLst = []
binaryDataOutBuff = None
@@ -238,9 +238,9 @@ def decode(self, audBytesBuff):
#out_chunk_header = AudChunkHeader()
(errGetChunk, bufferDataPos, out_chunk_header) = self.get_chunk_header(chunk_i, audBytesBuff, len(audBytesBuff))
if errGetChunk != 0:
# print "Error OR End file case while getting uncompressed chunk header!"
# print "Warning:: Error OR End file case while getting uncompressed chunk header!"
break
#print "Get uncompressed chunk header returned:: %d " % (out_chunk_header.id)
#print "Debug:: Get uncompressed chunk header returned:: %d " % (out_chunk_header.id)
#Cvirtual_binary out_chunk_data;
#AudFileNS::byte* byteChunkDataPtr = out_chunk_data.write_start(out_chunk_header.size_in);
(errorGCD, byteChunkDataLst) = self.get_chunk_data(audBytesBuff, bufferDataPos, out_chunk_header.size_in)
@@ -259,24 +259,24 @@ def decode(self, audBytesBuff):
chunk_i = 0
wIndex = 0
while (wIndex < cb_audio):
#print("chunkI: %d\t Windex: %d\t cb_audio: %d") % (chunk_i,wIndex,cb_audio)
#print("Debug:: chunkI= %d\t Windex= %d\t cb_audio= %d") % (chunk_i,wIndex,cb_audio)
#AudChunkHeader out_chunk_header;
#out_chunk_header = AudChunkHeader()
#errGetChunk = self.get_chunk_header(chunk_i, fs, startAudFilepos, endAudFilepos, out_chunk_header);
(errGetChunk, bufferDataPos, out_chunk_header) = self.get_chunk_header(chunk_i, audBytesBuff, len(audBytesBuff))
if errGetChunk != 0:
print "Error OR End file case while getting COMPRESSED chunk header!"
print "Warning:: Error OR End file case while getting COMPRESSED chunk header!"
break
#print "Get COMPRESSED chunk header returned:: headerInSize: %d headerOutSize: %d id: %d" % (out_chunk_header.size_in, out_chunk_header.size_out, out_chunk_header.id)
#print "Debug:: Get COMPRESSED chunk header returned:: headerInSize: %d headerOutSize: %d id: %d" % (out_chunk_header.size_in, out_chunk_header.size_out, out_chunk_header.id)
#Cvirtual_binary out_chunk_data;
#AudFileNS::byte* byteChunkDataPtr = out_chunk_data.write_start(out_chunk_header.size_in);
(errorGCD, byteChunkDataLst) = self.get_chunk_data(audBytesBuff, bufferDataPos, out_chunk_header.size_in)
# export decoded chunk to w (output) buffer (of SHORTS) at the point where we're currently at (so append there)
#print "byteChunkDataLst len: %d, size_in was: %d" % (len(byteChunkDataLst), out_chunk_header.size_in)
#print "Debug:: byteChunkDataLst len= %d, size_in was= %d" % (len(byteChunkDataLst), out_chunk_header.size_in)
decodedAudioChunkAsLst = decodeInstance.decode_chunk(byteChunkDataLst, out_chunk_header.size_out / self.get_cb_sample());
binaryDataOutLst.extend(decodedAudioChunkAsLst)
wIndex += out_chunk_header.size_out
#print("new Windex: %d\t cb_audio: %d") % (wIndex,cb_audio)
#print("Debug:: New Windex= %d\t cb_audio= %d") % (wIndex,cb_audio)
chunk_i += 1
binaryDataOutBuff = struct.pack('h'*len(binaryDataOutLst), *binaryDataOutLst)
return binaryDataOutBuff
@@ -302,15 +302,15 @@ def get_cb_sample(self):
#
if __name__ == '__main__':
# main()
print "Running %s as main module" % (my_module_name)
print "Debug:: Running %s as main module" % (my_module_name)
# assumes a file of name 000000.AUD in same directory
inAUDFile = None
errorFound = False
try:
inAUDFile = open(os.path.join('.','00000000.AUD'), 'rb')
except:
errorFound = True
print "Unexpected error:", sys.exc_info()[0]
print "Error:: Unexpected event:", sys.exc_info()[0]
raise
if not errorFound:
allOfAudFileInBuffer = inAUDFile.read()
@@ -320,5 +320,5 @@ def get_cb_sample(self):
inAUDFile.close()
else:
#debug
#print "Running %s imported from another module" % (my_module_name)
#print "Debug:: Running %s imported from another module" % (my_module_name)
pass
Oops, something went wrong.

0 comments on commit 234cdf1

Please sign in to comment.