That post seems to be missing.
djehuti 20 points 2 years ago path: 0 12466902, hotness: undefined, score: 20, children: 4
cheese_greater 7 points 2 years ago

Spank you, much :D

path: 0 12466902 12466961, hotness: undefined, score: 7, children: 3
steeznson 3 points 2 years ago

Ace Ventura on lemmy trying to understand file encodings

path: 0 12466902 12466961 12488742, hotness: undefined, score: 3, children: 0
AsudoxDev 3 points 2 years ago

Spank?

path: 0 12466902 12466961 12472037, hotness: undefined, score: 3, children: 1
intensely_human 2 points 2 years ago

Spank

path: 0 12466902 12466961 12472037 12484039, hotness: undefined, score: 2, children: 0
palebluethought 12 points 2 years ago

can it? Sure, most any arrangement of bits can be converted into some kind of Unicode text. Can it be converted to something meaningful or readable? No, some formats are plain text (.txt, .ini, .json, .html for some random examples) that are meant to be read by humans, and others are binary formats that are only meaningful when decoded by a computer into specific data structures inside a piece of software.

path: 0 12466904, hotness: undefined, score: 12, children: 0
Nibodhika 6 points 2 years ago

At the end of the day data is just binary, i.e. it's composed of 0 and 1. What those 0 and 1 represent is mostly irrelevant to this discussion. The short version is that 01000001 can mean A or it can mean that a given pixel is 65/256 red, or that the speaker should vibrate in a specific frequency, etc, etc.

So what happens when you open a file that's not text in a text editor? Well, some of the 0 and 1 make up gibberish, or characters that are not meant to be printed. Fun fact, you should be able do this the other way around too, i.e. open a text as an image, but again it will be gibberish, and most likely would not load since images have lots of information that relate to size, compression, etc, that if incorrect the program won't know what to do, but because text can always be valid it will always work, although sometimes your editor might show weird thing in the places where there's a non-printable character.

path: 0 12491239, hotness: undefined, score: 6, children: 0
AbouBenAdhem 6 points 2 years ago path: 0 12467053, hotness: undefined, score: 6, children: 10
cheese_greater 1 point 2 years ago

Can you comment on the specific makeup of a "rendered" audio file in plaintext, how is the computer representing every little noise bit of sound at any given point, the polyphony etc?

What are the conventions of such representation? How can a spectrogram tell pitches are where they are, how is the computer representing that?

Is it the same to view plaintext as analysing it with a hex-viewer?

path: 0 12467053 12467099, hotness: undefined, score: 1, children: 9
Ephera 8 points 2 years ago

There's two things at play here.

MP3 (or WAV, OGG, FLAC etc.) provide a way to encode polyphony and stereo and such into a sequence of bytes.

And then separately, there's Unicode (or ASCII) for encoding letters into bytes. These are just big tables which say e.g.:

  • 01000001 = uppercase 'A'
  • 01000010 = uppercase 'B'
  • 01100001 = lowercase 'A'

So, what your text editor does, is that it looks at the sequence of bytes that MP3 encoded and then it just looks into its table and somewhat erronously interprets it as individual letters.

path: 0 12467053 12467099 12467560, hotness: undefined, score: 8, children: 0
vithigar 6 points 2 years ago

I think you are conflating a few different concepts here.

Can you comment on the specific makeup of a “rendered” audio file in plaintext, how is the computer representing every little noise bit of sound at any given point, the polyphony etc?
What are the conventions of such representation? How can a spectrogram tell pitches are where they are, how is the computer representing that?

This is a completely separate concern from how data can be represented as text, and will vary by audio format. The "simplest", PCM encoded audio like in a .wav file, doesn't really concern itself at all with polyphony and is just a quantised representation of the audio wave amplitude at any given instant in time. It samples that tens of thousands of times per second. Whether it's a single pure tone or a full symphony the density of what's stored is the same. Just an air-pressure-over-time graph, essentially.

Is it the same to view plaintext as analysing it with a hex-viewer?

"Plaintext" doesn't really have a fixed definition in this context. It can be the same as looking at it in a hex viewer, if your "plaintext" representation is hexadecimal encoding. Binary data, like in audio files, isn't plaintext, and opening it directly in a text editor is not expected to give you a useful result, or even a consistent result. Different editors might show you different "text" depending on what encoding they fall back on, or how they represent unprintable characters.

There are several methods of representing binary data as text, such as hexadecimal, base64, or uuencode, but none of these representations if saved as-is are the original file, strictly speaking.

path: 0 12467053 12467099 12467455, hotness: undefined, score: 6, children: 0
AbouBenAdhem 3 points 2 years ago

Most binary-to-text encodings don’t attempt to make the text human-readable—they’re just intended to transmit the data over a text-only medium to a recipient who will decode it back to the original binary format.

path: 0 12467053 12467099 12467190, hotness: undefined, score: 3, children: 6
cheese_greater 1 point 2 years ago

I do understand I'm not able to read it myself, I'm more curious about the architecture of how that data is represented and stored and conceptually how such representation is practically organized/reified...

path: 0 12467053 12467099 12467190 12467279, hotness: undefined, score: 1, children: 5
AbouBenAdhem 3 points 2 years ago

The original binary format is split into six-bit chunks (e.g., 100101), which in decimal format correspond to the integers from 0 to 63. These are just mapped to letters in order:

  1. 000000 = A,
  2. 000001 = B,
  3. 000010 = C,
  4. 000011 = D,

etc.—it goes through the capital letters first, then lower-case letters, then digits, then “+” and “/”. It’s so simple you could do it by hand from the above description, if you were looking at the data in binary format.

path: 0 12467053 12467099 12467190 12467279 12467760, hotness: undefined, score: 3, children: 0
intensely_human 2 points 2 years ago

One representation of a sound wave is a sequence of amplitudes, expressed as binary values. Each sequential chunk of N bits is a number, and that number represents the amplitude of the sound signal at a moment in time. Those moments in time are spaced at equal intervals. One common sampling rate is 44.1 kHz.

That number is chosen because of the nyquist-shannon sampling rate theorem, in combination with the fact that humans tend to be able to hear sounds up to 20 kHz.

The sampling rate theorem says that if you want to reproduce a signal containing information at up to X frequency, you need to sample it at 2X frequency.

To learn more about this topic, look for texts, classes, or videos on “signal processing”. It’s often taught in classes that also cover electronic circuits.

Here is an example of such a text

That’s pretty dense reading, but if you’re willing to stop and learn any math you encounter while reading it, it will probably blow your mind into a whole new level of understanding the world.

path: 0 12467053 12467099 12467190 12467279 12484113, hotness: undefined, score: 2, children: 3
leaky_shower_thought 4 points 2 years ago

technically, yes. all unprintable binary can be resolved to 64 printable characters. but that resulting string may not be english or any human language.

path: 0 12467043, hotness: undefined, score: 4, children: 3
cheese_greater 1 point 2 years ago

But its still contains the actual data in a faithfully reproducible/useable way?

path: 0 12467043 12467061, hotness: undefined, score: 1, children: 2
vithigar 6 points 2 years ago

Yes. Decoding a base64 encoded string will give you back the exact original data.

Importantly though, this isn't what you're seeing when you open files in a text editor as you describe in your original post, and if you copied the text of those files and saved a new copy it's very likely that it would not reproduce correctly.

path: 0 12467043 12467061 12467183, hotness: undefined, score: 6, children: 0
leaky_shower_thought 4 points 2 years ago

yes, this method doesn't lose any bits. one of its primary use before was email which was strictly text only.

path: 0 12467043 12467061 12467119, hotness: undefined, score: 4, children: 0
JASN_DE 3 points 2 years ago

Are those binary files by any chance?

path: 0 12466927, hotness: undefined, score: 3, children: 6
cheese_greater 2 points 2 years ago

I just mean like any file (pdf, jpeg, mp4, mp3, exe—

mp4/mp3 most famously for me

I find it so damn cool and incredible I can record something/anything right now and open the audio in a text file and its all right there—albeit in an incomprehensible format but there altogether.

Its like a thinking rock etching sound into stone

path: 0 12466927 12466979, hotness: undefined, score: 2, children: 5
ptz 8 points 2 years ago

If you're on Linux, you can convert that to something more human readable by piping it to base64. It works with any file, but I'll use an image here:

cat image.webp | base64

Which yields:

UklGRroEAABXRUJQVlA4WAoAAAAgAAAAYwAAQgAASUNDUKACAAAAAAKgbGNtcwRAAABtbnRyUkdC
IFhZWiAH6AAIABoADgAJACBhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAA
AADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1k
ZXNjAAABIAAAAEBjcHJ0AAABYAAAADZ3dHB0AAABmAAAABRjaGFkAAABrAAAACxyWFlaAAAB2AAA
ABRiWFlaAAAB7AAAABRnWFlaAAACAAAAABRyVFJDAAACFAAAACBnVFJDAAACFAAAACBiVFJDAAAC
FAAAACBjaHJtAAACNAAAACRkbW5kAAACWAAAACRkbWRkAAACfAAAACRtbHVjAAAAAAAAAAEAAAAM
ZW5VUwAAACQAAAAcAEcASQBNAFAAIABiAHUAaQBsAHQALQBpAG4AIABzAFIARwBCbWx1YwAAAAAA
AAABAAAADGVuVVMAAAAaAAAAHABQAHUAYgBsAGkAYwAgAEQAbwBtAGEAaQBuAABYWVogAAAAAAAA
9tYAAQAAAADTLXNmMzIAAAAAAAEMQgAABd7///MlAAAHkwAA/ZD///uh///9ogAAA9wAAMBuWFla
IAAAAAAAAG+gAAA49QAAA5BYWVogAAAAAAAAJJ8AAA+EAAC2xFhZWiAAAAAAAABilwAAt4cAABjZ
cGFyYQAAAAAAAwAAAAJmZgAA8qcAAA1ZAAAT0AAACltjaHJtAAAAAAADAAAAAKPXAABUfAAATM0A
AJmaAAAmZwAAD1xtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAEcASQBNAFBtbHVjAAAAAAAA
AAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJWUDgg9AEAALAQAJ0BKmQAQwA+8WSmTqmlKCYvmWqp
MB4JZQDLnNaF2NMD2L3xQGb5nmLiGhGWxQuD8kwUSXF0u2UTgX0YrR3MY2SsRCNEQ8hZ6WkCUTih
LdmsElHZVzoMwO/fj4X/ZSNT2R9qgxwqgEed891j4KCNRLK/tUbG3hZ3Mw2kixguSFIEcAgBtv8w
eAu0PwAA/upMzBqq+dcN8viO7FpqpV6GvPcRILm+HsOQblnpHx03lASjGlSyGbkKUD3xA5KOqgq/
VEUJ4qF9VoAYFbFhQRAgkvmREk5umMj8sr9Np95+n/oP2Aq2VW5xU4F1xpD8Vd4Dp7Phwm9w/Dnf
94djRROFRYPZeg/1Q/qiROFRVRu2nBcgndbhc0x0h+kgvT/naeJOEqwNjYPlIiw/DGuxav7+x09R
mf2mJto3ineDqfyMWUN83PmKqzGHkYGhZrTU478qjlQucDzWkwobnUmzhE6I+mDYkfiUVPcHyXbf
xXRStyPiPZAkJZrE9OrjFNUeljRQdVTQqeBsy+O9VwDLU5GcKhBQHa4cj+/DGqUhi74WH0EuHsb3
EgZVNc1FbRm5QFOpjDSprGIRYxe6sFFDrDOg4DhWZRnOa7s68pGaDDpbqrORxzPHXPbs55/1HTas
DDGzKFmTG4hJ2GUZKqjPcQ+MAAAA

Copy that into a text file and pass it to base64 with the decode flag, and you'll get the original binary:

cat data.txt | base64 -d > data.bin

Inspect it to see what kind of file it is:

file data.bin -> data.bin: RIFF (little-endian) data, Web/P image

Rename it so you can just double-click it to open it:

mv data.bin data.webp

Enjoy the surprise.

You can also print files like that, scan them using OCR, and then restore them. A very inefficient way to do backups, but it works.

path: 0 12466927 12466979 12467137, hotness: undefined, score: 8, children: 3
cheese_greater 3 points 2 years ago

How is it representing it tho? Like does it have woven in there an array of hexcode colors for every microscopic pixel that makea up the picture.

Are images and audio files just arrays of frames which are arrays of pixels and sound units?

path: 0 12466927 12466979 12467137 12467228, hotness: undefined, score: 3, children: 2
ptz 4 points 2 years ago

It just converts the raw binary data into character encoding, so it doesn't matter what the source is (image, video, database file, etc). The source binary data is taken 6 bits at a time, then this group of 6 bits is mapped to one of 64 unique characters.

The decoding process is just the reverse of that: mapping the data back to binary form.

https://en.wikipedia.org/wiki/Base64

path: 0 12466927 12466979 12467137 12467228 12467288, hotness: undefined, score: 4, children: 0
Num10ck 2 points 2 years ago

the answer to your how question is as needed.

some image and audio formats (especially older ones) are like that, yes. others use compression or other techniques to suit their need. like a sound can be a raw recording sample. or a sound can be described with Attack/Decay/Sustain/Release, along with octave and note etc. so a MIDI file is an audio file format without samples.

i once created an image format to be used for spiraling out images, instead of pixel arrays they were concentric circles of pixels that i could easily offset.

path: 0 12466927 12466979 12467137 12467228 12483570, hotness: undefined, score: 2, children: 0
Toes 1 point 2 years ago path: 0 12466927 12466979 12469913, hotness: undefined, score: 1, children: 0

thanks for using Leebra!

go to feed...