Skip to content

Instantly share code, notes, and snippets.

@MilesLitteral
Last active March 15, 2023 06:37
Show Gist options
  • Save MilesLitteral/c6cca468c277909ffedcdae3794d2d25 to your computer and use it in GitHub Desktop.
Save MilesLitteral/c6cca468c277909ffedcdae3794d2d25 to your computer and use it in GitHub Desktop.
Sonic Graffiti Lib's Manifesto
==How many bytes can a QR Code store at most?==
The maximum number of bytes that a QR code can store depends on the type of QR code and the error correction level used.
The maximum storage capacity for a standard QR code (Version 40) with high error correction level is 2953 bytes of data.
However, it's important to note that this maximum capacity is rarely achieved in practice, as the amount of data that can
be stored in a QR code depends on factors such as the type of data being stored (e.g., alphanumeric, binary, etc.),
the size and complexity of the QR code, and the scanning device's ability to read the code accurately.
In general, it's best to aim for a QR code that is large enough to be easily scanned and contains only the necessary data,
rather than trying to store as much information as possible in a single code.
==How many bytes can a JAB Code store at most?==
JAB Code is a color two-dimensional matrix symbology whose basic symbols are made of colorful square modules arranged in either square
or rectangle grids. JAB Code has two types of basic symbols, named as primary symbol and secondary symbol. A JAB Code contains one
primary symbol and optionally multiple secondary symbols. Primary symbols contain four finder patterns located at the corners of the symbol, while secondary symbols contain no finder pattern. A secondary symbol can be docked to a primary symbol or another docked secondary symbol in either horizontal or vertical direction. JAB Code can encode from small to large amount of data correlated to user-specified percentages of error correction.
Thank you for providing more information on JAB Code. According to their website, the maximum storage capacity of a JAB Code depends
on the version of the code, the size of the code, and the level of error correction used.
For example, a JAB Code version 10
with high error correction level can store up to 1050 bytes of data, while a JAB Code version 40
with the same error correction level can store up to 9,218 bytes of data.
It's important to note that the actual amount of data that can be stored in a JAB Code
depends on factors such as the type of data being encoded, the size and complexity of the code,
and the scanning device's ability to read the code accurately.
The maximum storage capacity of a JAB Code can be measured in bytes, not in megabytes.
However, we can convert the maximum storage capacity of a JAB Code in bytes to megabytes
by dividing the number of bytes by 1,000,000.
For example, a JAB Code version 40 with high error correction level
can store up to 9,218 bytes of data. To convert this to megabytes,
we would divide 9,218 by 1,000,000, which gives us approximately 0.009218 megabytes (or 9.218 kilobytes).
It's important to keep in mind that the actual
amount of data that can be stored in a JAB Code depends on factors such as the type of data being encoded,
the size and complexity of the code, and the scanning device's ability to read the code accurately. Additionally,
while JAB Code is designed to store large amounts of data, it may not be the most efficient or practical solution for
storing large amounts of information compared to other digital storage formats.
==How many bytes can an MP3 store at most?==
The amount of data that can be stored in an MP3 file depends on various factors such as the bit rate,
the length of the audio, and the complexity of the audio content.
MP3 is a lossy audio compression format, which means that it uses various compression techniques to reduce
the file size of an audio recording while sacrificing some of the original audio quality.
The bit rate of an MP3 file determines the amount of data that is encoded per second of audio,
which in turn affects the file size.
For example, an MP3 file encoded at 128 kbps (kilobits per second) will typically have a file size of around 1 MB (megabyte)
per minute of audio. Therefore, a 3-minute MP3 file encoded at 128 kbps will have a file size of approximately 3 MB.
Higher bit rates will result in larger file sizes,
while lower bit rates will result in smaller file sizes with lower audio quality.
The maximum file size of an MP3 is not specified by the format itself, but rather by the available storage
space on the device or media where the file is stored.
If one wanted to store an MP3 in a QR Code how might they go about it?
It is possible to store an MP3 file in a QR code by encoding the binary data of the file into the QR code.
Here are the general steps to follow:
Convert the MP3 file to binary format. Most programming languages have libraries or built-in functions
to read and convert files to binary data.
Break the binary data into smaller chunks that can fit into the QR code.
QR codes have a limited storage capacity, so the binary data needs to be broken into smaller pieces.
Encode the binary data into a QR code.
There are many QR code generators available online that can encode binary data into a QR code.
Save the QR code as an image file. Once the binary data is encoded into the QR code, it can be saved as an image file
such as PNG or JPEG.
To decode the QR code and retrieve the MP3 file:
Scan the QR code using a QR code reader app on a smartphone or tablet.
The app will read the binary data from the QR code and decode it into the original MP3 file.
Save the MP3 file to the device or listen to it directly from the QR code reader app.
It's important to note that encoding an MP3 file into a QR code will result in a large and complex QR code.
The size and complexity of the QR code may make it difficult to scan with some QR code readers, and the resulting
file may not be of the highest quality due to the compression used in the MP3 format. Additionally, it may be more
practical to store the MP3 file directly on a device or share it through a file sharing service rather than using a QR code.
If JAB Code can store 9,218 bytes at most how many JAB Codes would need to be made to store 3MBs?
To determine how many JAB Codes would be needed to store 3 MB of data, we first need to convert 3 MB to bytes.
1 MB is equal to 1,000,000 bytes, so 3 MB is equal to 3,000,000 bytes.
Next, we divide the total number of bytes by the maximum storage capacity of a single JAB Code.
3,000,000 bytes ÷ 9,218 bytes = 325.87
So we would need approximately 326 JAB Codes to store 3 MB of data.
It's important to keep in mind that dividing the data into multiple JAB Codes may not be the most practical or efficient
solution depending on the context. If possible, it may be better to store the data in a different format that can handle
larger amounts of data in a single file.
==Perhaps it is more practical, however, I hope to perfect a bespoke method of such storage==
if you are looking to develop a bespoke method of storing data using JAB Codes, you may want to consider the following factors:
Optimize the data for JAB Code: Since JAB Codes have a limited storage capacity, it is important to optimize the data for
efficient storage. This can involve compressing the data or breaking it into smaller chunks that can fit into a JAB Code.
Develop an algorithm for splitting the data: If the data cannot fit into a single JAB Code, you will need to develop an
algorithm for splitting the data into multiple JAB Codes. This algorithm should take into account the maximum storage capacity of
each JAB Code and ensure that the data is split in a way that is easy to reassemble.
Develop an algorithm for reassembling the data: Once the data is split into multiple JAB Codes, you will need to develop
an algorithm for reassembling the data. This algorithm should be able to detect and correct errors that may occur during
transmission or storage.
Test the method: Before using the method to store important data, it is important to thoroughly test it to ensure that it is
reliable and efficient. This can involve testing the method underdifferent conditions and scenarios to
identify any potential issues.
By considering these factors, you can develop a bespoke method of storing data using JAB Codes that
is optimized for your specific needs.
Here's an example of pseudocode in C++ that demonstrates splitting a file into JAB Codes and reassembling it:
c++```#include <iostream>
#include <fstream>
#include <string>
#include <vector>
// Function to split a file into JAB Codes
std::vector<std::string> splitIntoJABCodes(std::string filename) {
std::ifstream input(filename, std::ios::binary);
std::vector<std::string> jabCodes;
int maxJabCodeSize = 9218;
char buffer[maxJabCodeSize];
while (input.read(buffer, maxJabCodeSize)) {
std::string jabCode(buffer, buffer + input.gcount());
jabCodes.push_back(jabCode);
}
if (input.gcount() > 0) {
std::string jabCode(buffer, buffer + input.gcount());
jabCodes.push_back(jabCode);
}
input.close();
return jabCodes;
}
// Function to reassemble a file from JAB Codes
void reassembleFromJABCodes(std::vector<std::string> jabCodes, std::string filename) {
std::ofstream output(filename, std::ios::binary);
for (std::string jabCode : jabCodes) {
output.write(jabCode.c_str(), jabCode.size());
}
output.close();
}
// Example usage
int main() {
std::string inputFilename = "myFile.mp3";
std::string outputFilename = "myFile_reassembled.mp3";
std::vector<std::string> jabCodes = splitIntoJABCodes(inputFilename);
reassembleFromJABCodes(jabCodes, outputFilename);
return 0;
}```
This example demonstrates how to split a file into JAB Codes with a maximum size of 9218 bytes and how to reassemble the file from
the JAB Codes. The splitIntoJABCodes function takes a file name as input and returns a vector of strings, where each string represents
a JAB Code. The reassembleFromJABCodes function takes a vector of JAB Codes and an output file name as input and reassembles the
original file.
Note that this is just an example of pseudocode and may need to be adapted to fit your specific use case.
Here is an example of how you can split a file into JAB Codes and reassemble it in Haskell:
haskell```
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import Data.List.Split (chunksOf)
-- Function to split a file into JAB Codes
splitIntoJABCodes :: FilePath -> IO [ByteString]
splitIntoJABCodes filePath = do
fileContents <- BS.readFile filePath
let maxJABCodeSize = 9218
jabCodes = chunksOf maxJABCodeSize fileContents
return jabCodes
-- Function to reassemble a file from JAB Codes
reassembleFromJABCodes :: FilePath -> [ByteString] -> IO ()
reassembleFromJABCodes filePath jabCodes = do
let fileContents = BS.concat jabCodes
BS.writeFile filePath fileContents
-- Example usage
main :: IO ()
main = do
let inputFilePath = "myFile.mp3"
outputFilePath = "myFile_reassembled.mp3"
jabCodes <- splitIntoJABCodes inputFilePath
reassembleFromJABCodes outputFilePath jabCodes```
In this example, the splitIntoJABCodes function reads in the contents of a file as a ByteString,
splits it into JAB Codes using the chunksOf function from the Data.List.Split module, and returns a list of ByteStrings.
The reassembleFromJABCodes function takes a list of JAB Codes as input, concatenates them into a single ByteString, and writes
it to a file using the BS.writeFile function.
Note that this is just an example, and it may need to be modified to fit your specific use case.
Additionally, it is important to thoroughly test the code to ensure that it is reliable and efficient.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment