Author Topic: Sound for calculators with bad ram  (Read 35630 times)

0 Members and 1 Guest are viewing this topic.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Sound for calculators with bad ram
« Reply #15 on: July 26, 2010, 06:36:46 pm »
A lot of frustration has occurred since my last post. Although no one really cares, here is what happened.

1. I got 22khz working.
2. Ti-connect refused to send the 1250k app via usb.
3. After 30 minutes via silverlink, my batteries died.
4. I got compression with LZ77 working, (uses past 16k as a reference for copying)
5. .wav files compress .5% via LZ77.
6. New compression algorithm cuts 5%-10%
7. New batteries, sent via silverlink in 30 min, invalid
8. Installed tilp, spent lots of time working it out.
9. Tilp crashes on 1250k but sends smaller ones.
10. Those smaller ones are invalid.
11. Got wabbitsign instead of wappsign and signing works.
12. Tilp stops working all together.
13. Reinstall Ti-Connect, and send the new 1 minute sample.

Here is the video I promised.


After my complete failure with LZ77, I looked at the hex of the .wav files to see what I could do. I noticed that there were lots of numbers in the $70's and $80's. So my compressor writes numbers between 79 and 87 as nibbles to save space. So instead of 79 7A 7B 7C 7D 7E 7F 80 81 82. It writes 00 12 34 56 78 9A 00. The 00's are flags telling when compression starts and stops. This works decently, especially with quiet sections.

If anyone has any suggestions to compression techniques I'd love to hear them. The only problem is that they have to be able to get the next byte in exactly 108 t-states. But I do have a whole 16k ram page to work with.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Sound for calculators with bad ram
« Reply #16 on: July 26, 2010, 06:49:25 pm »
That. Sounds. Awesome! Excellent work! :D
Hm... compression techniques...
At any rate, excellent. Should've done a different song, though :P
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Sound for calculators with bad ram
« Reply #17 on: July 26, 2010, 07:03:31 pm »
What about Huffman coding?  I remember it was used for a previous sound player... although i dont remember which.  It seems to be the type which would help with this type of data tho.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Sound for calculators with bad ram
« Reply #18 on: July 26, 2010, 07:57:17 pm »
I was thinking about huffman before, but it wasn't untill I just went to the wikipedia page that I fully understood how it works. I'll see if I can get that working. Though it might be hard with 108 t-states.

Edit:
   These monster apps screw with your calc. Mirage crashes, my zStart crashes. All items are selected in mode menu. Weird...
« Last Edit: July 26, 2010, 07:58:39 pm by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Sound for calculators with bad ram
« Reply #19 on: July 26, 2010, 08:09:33 pm »
Did you forget to restore IY?
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Sound for calculators with bad ram
« Reply #20 on: July 26, 2010, 08:29:26 pm »
Yes.

My program used to jump to 0000 when it was done, it doesn't now.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Sound for calculators with bad ram
« Reply #21 on: July 27, 2010, 08:26:12 am »
Cool stuff! Quality is quite good too. What size was the sample heard in the video?

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Sound for calculators with bad ram
« Reply #22 on: July 27, 2010, 09:07:50 am »
1,196,032 bytes. The first 1 is cut off in the memory menu. But this number makes sense as divides to 73 pages.

Anyways, I am going to use huffman compression. I am hoping that 13 bits is enough for a maximum. I would then multiply that to 14 bits and use a 16k look up table. I am also going to cut the rate to 20,000 so that I will have 74 extra t-states to work with.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Sound for calculators with bad ram
« Reply #23 on: July 27, 2010, 10:06:51 am »
Thank you for your effort, to bring "true sound" to new TI-84+SEs.

Compression is really useful to something like this.
You are really on the limit of the z80 CPU at 15MHz. ;D
« Last Edit: July 27, 2010, 10:07:10 am by Galandros »
Hobbing in calculator projects.

SirCmpwn

  • Guest
Re: Sound for calculators with bad ram
« Reply #24 on: July 27, 2010, 11:02:18 am »
Wow, this is awesome.  If you would be so kind as to send me the source code ;) I may be able to use it to play sound off a flash drive, which would be epic.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Sound for calculators with bad ram
« Reply #25 on: July 27, 2010, 11:23:05 am »
Sure, I'll send it to you when I'm done. The only problem is that you have only and exactly 182 t-states to get a byte. I'm not exactly sure how you'd do that with usb. But if you pull it off, that'd be nice.

Actually, the playing part is finished, compression's all I'm working on. You'll have to modify it a bit to fit your needs, but here's how it works. You have to figure out exactly how many t-states you have to work with. You do this by taking your processor speed and dividing it by your sample frequency. Mine is 15,800,000 / 22,050 = 716 t-states. Then you have to subtract the length of the subroutine, which is 516 delay + 41 = 557. You also have to subtract the code that makes the jump, 51. This leaves you with 716 - 557 - 51 = 108. But your not finished, you also have to exx out your code. So 108 - 4 - 4= 100. 100 t-states for 22,050. Going to 20,000 hz will give you an extra 74. So 174 is the magic number to work with.

As far as the source, you can delete all of the _44100: data. I just keep it because it took so long to make. You should also delete the _0: _1: stuff as that is my Huffman decompressor.

Memory wise. The whole thing runs in C000-FFFF. Which means that 4000-BFFF are free to use.
« Last Edit: July 27, 2010, 11:23:47 am by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Sound for calculators with bad ram
« Reply #26 on: July 27, 2010, 01:31:55 pm »
If we are reading from a usb flash drive, decompression shouldn't be needed, that could help.
Hobbing in calculator projects.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Sound for calculators with bad ram
« Reply #27 on: July 27, 2010, 03:10:30 pm »
1,196,032 bytes. The first 1 is cut off in the memory menu. But this number makes sense as divides to 73 pages.

Anyways, I am going to use huffman compression. I am hoping that 13 bits is enough for a maximum. I would then multiply that to 14 bits and use a 16k look up table. I am also going to cut the rate to 20,000 so that I will have 74 extra t-states to work with.
Wow, that's actually pretty large. O_o Are you going to allow an option on your converter to select different sample rates so that people can include longer pieces?
*edit* this reminds me alot of Jim E's Realsound. =)
« Last Edit: July 27, 2010, 03:11:19 pm by Art_of_camelot »

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Sound for calculators with bad ram
« Reply #28 on: July 27, 2010, 04:30:23 pm »
This was inspired by Realsound ;D
Nice to see you have compression. I can't wait to see how much the size goes down :P
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Sound for calculators with bad ram
« Reply #29 on: July 28, 2010, 04:28:56 pm »
Prepare for epicness. I wrote my huffman compressor, (which was actually somewhat hard), and it got a ratio of 60%. That means 2 min and 20 seconds of music.

But!... Some of the numbers are encoded as 19 bits. 12 bits has pushed my decompressor 8 t-states over my max, which is acceptable, but 19 is just out of the question. So I am going to try to sound clip the edges of the song to fix the problem. I'll make a cut off of say 30 instances, and anything with less than 30, gets bumped closer to $80. I'm hoping that this can give me a smaller prefix and thereby make this possible.

Edit:
    That number is more like 400, not 30.
« Last Edit: July 28, 2010, 05:10:14 pm by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112