Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Keoni29 on June 26, 2012, 02:31:27 am
-
Heya, I built a digital to analog converter for my TI84+
I can write values to it easily using a subroutine I wrote. WA(nibble) writes a 4 bit value to the DAC
Now I need some 4 bit samples which I can use with it. Preferably compressed (two nibbles in a byte) and stored in an appvar.
Does anyone know how to accomplish this?
-
Ok here's what I'm gonna do:
I'm load audio samples in audacity and I convert them as 8 bit raw. I copy the raw hex values and I paste them in sourcecoder. Then I copy the values divided by 16 to an appvar.
-
Double-post tho I think it's not too big problem.
Yeah I think that's what you should do.
-
Ok here's what I'm gonna do:
I'm load audio samples in audacity and I convert them as 8 bit raw. I copy the raw hex values and I paste them in sourcecoder. Then I copy the values divided by 16 to an appvar.
Will that work properly? O.O I guess there isn't a 4bit downsampling in Audacity...
-
Ok here's what I'm gonna do:
I'm load audio samples in audacity and I convert them as 8 bit raw. I copy the raw hex values and I paste them in sourcecoder. Then I copy the values divided by 16 to an appvar.
Will that work properly? O.O I guess there isn't a 4bit downsampling in Audacity...
Jimbauwen's converter still glitches, so: no it does not work properly :P
-
Ok here's what I'm gonna do:
I'm load audio samples in audacity and I convert them as 8 bit raw. I copy the raw hex values and I paste them in sourcecoder. Then I copy the values divided by 16 to an appvar.
Will that work properly? O.O I guess there isn't a 4bit downsampling in Audacity...
Jimbauwen's converter still glitches, so: no it does not work properly :P
If you know any computer programming languages, you could probably do the conversion yourself. The .wav file format is not that complicated and I've written 3 programs already that take its data.
If that computer programming language happens to be C++, you can borrow the source to my TruSound and TruVid.
-
Hey, it doesn't glitch :P
It does exactly what you ask ;)
Here is the code:
#!/usr/bin/env python
# This program converts 8 bit DEC files to 4 bit
import sys
def fixHex(h):
res = h.replace("0x","").upper()
if len(res) == 1:
res = "0"+res
return res
if len(sys.argv) < 2:
print("python convert.py <filename>")
exit(-1)
try:
file = open(sys.argv[1], "rb")
except:
print(sys.argv[1] + " can not be opened!")
exit(-1)
data = file.read()
out = ""
try:
for i in range(len(data)):
if i%4 == 0:
part1 = (ord(data[i])>>4)<<4
part2 = ord(data[i+3])>>4
out += fixHex(hex(part1+part2))
except:
print("Warning, file size odd! Last byte ignored.")
print(out[:-1])
Example input data:
A1 A1 B2 B2 3C 3C 4D 4D (but in binary form)
Output:
AB34 (in string)
So, what is does is loop 4 bytes a time over all the data.
The first byte and the third byte is what I need as the second and fourth are just the same.
Then I do there operations each loop:
a = (ord(byte1)>>4)<<4
b = (ord(byte3)>>4)
output = a + b
-
The data is probably signed.
-
What would that change ?
I assume the first bit indicates the sign, and that bit doesn't get lost.