Compress list

Screenshot 2024-06-04 8.57.15 AM
if i have a really really long list does anyone know a way i can compress the data so i can have multiple long lists and be able to save the project

Well, you could look into compression algorithms, like the one used for zip files.

they take so long. i was thinking converting it into a sound or costume

I'm not sure how much smaller the data would be, because I think snap creates wav files for sounds (I haven't checked, so idk), but I'm prettt sure it does create png files for costumes, so storing data in a costume could work (although a single color channel in one pixel is capped at 255).

ik. my numbers shouldnt ever exeed 255. my issue is that the largest costume is 172800 pixels. so i need to convert my list to include both the r g b and a of every pixel.

even then my list is far too long

You can use the unicode of [] and unicode () as letter blocks to compress the numbers into Unicode characters from 0-255. All Unicodes from 0-255 are 1 byte, and when I compress the items using it, you can save up to 66% of space.

can you show me an example with a list like the one in here https://snap.berkeley.edu/project?username=avi_shor&projectname=compression%2Fdecompression

untitled script pic (15)

Encoding

untitled script pic (16)

Decoding

im not compressing with costumes yet

What are you compressing now? I don't know what are you doing now.

a list

May I suggest you google procedural generation? It may not be what you're looking for exactly, but it might be.

It's the idea that instead of storing, for example, a costume as an image, you store the math that creates the costume and recall that as you need it.

wouldnt that take long to calculate

We had a discussion on data compression on this forum not so long ago. You may find easy-to-use ideas here.

i just needed a better way to store a lot of hashed songs. the costume way works ok i think

The whole idea of hashing is that it already compresses the song a lot, because for your application (i.e., not actually playing the song) it's okay for the representation to lose most of the information.

Somewhere (I really have to get my books organized) I have a book in which pieces of music (emphasizing classical, but some popular music songs too) are encoded by taking the melody and representing each note in a form that could be computerized in two bits:
+ This note is higher in pitch than the note before it.
- This note is lower in pitch than the note before it.
* This note is at the same pitch as the note before it.
The first note is omitted because there is no note before it. The durations of the notes are ignored. The author chose this representation to be accessible to non-musicians; even people who can't hold a tune can generally say whether this note is higher or lower than that note. The amazing thing is that in a huge collection of pieces of music, it typically takes only a few notes to determine which one you're thinking of, or at least to narrow it down to a few possibilities. (The book is sorted by this representation, not by title or composer or anything, so that when you have a tune in your head you can find out what it is. So in a way the book is directly relevant to your Shazam project; it's the pre-computer version of Shazam!)

This is a remarkable example of extreme compression; you couldn't use it to play back the music, even with low fidelity. But it's great for identifying a piece of music. You can't use it directly in your project because starting from an audio sample, rather than from sheet music, it's too hard to determine the melody. But it's a perfect example of a hash of a song to think about what hashing means.

TL;DR: If you are worrying about compressing your hash codes, you're not hashing aggressively enough. I bet you could look up the algorithm the real Shazam uses.

To a first approximation, taking the same stream of bits and reinterpreting it as representing something different (such as reinterpreting a sound sample as a picture) doesn't change the number of bits! Yes, it's true that some picture representations are more compressed than the raw pixels, and so yes, maybe you can get Snap! to do part of the work for you, since we use a compressed picture representation for export. But if you want to compress sounds, you'd probably do better to look into compressed file formats meant specifically for sounds, such as MP3.

ok

Nope. The fun part is computers are math. They don't care about anything they see, they just see a list of instructions and execute them.

Which is also why we have bugs and malware, unfortunately. (handwaving a whole lot of other things, keeping in mind that the simple version is almost always exactly the opposite of what actually happens)

Specifically, the stuff I'm thinking of specifically stacked blocks together to define a node graph and then stored all the blocks as call codes, so you can store the math, and a list of timing and make animated music videos that go for ten or so minutes and are tiny in file size. Like, 65536 bytes in size tiny.

It's that tool in particular that led me, eventually to snap! Namely, they wrote in C++ and I wanted to learn how they did it, and while I have a pretty good idea how they do it, I can't replicate it for a whole host of reasons. but that's neither here nor there to this discussion.