Autosave: 2025-01-01 15:57:56
|
|
@ -1,9 +0,0 @@
|
||||||
---
|
|
||||||
tags: []
|
|
||||||
created: Friday, December 27, 2024
|
|
||||||
---
|
|
||||||
# Binary_encoding_of_sound
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
---
|
|
||||||
tags: [databases, SQL, SQLite]
|
|
||||||
created: Wednesday, November 13, 2024
|
|
||||||
---
|
|
||||||
|
|
||||||
# SQLite
|
|
||||||
|
|
||||||
## Enabling foreign key constraints
|
|
||||||
|
|
||||||
Foreign key constraints are not enabled by default - it is very permissive. You
|
|
||||||
must manually turn them on, as part of the connection process:
|
|
||||||
|
|
||||||
```py
|
|
||||||
connection = sqlite3.connect("my_database.db")
|
|
||||||
connection.execute("PRAGMA foreign_keys = ON")
|
|
||||||
```
|
|
||||||
|
|
||||||
## INSERT OR IGNORE INTO
|
|
||||||
|
|
||||||
If table has a `UNIQUE` constraint on a field, insert if it is unique otherwise
|
|
||||||
skip without throwing a constraint error.
|
|
||||||
|
|
||||||
```sql
|
|
||||||
INSERT OR IGNORE INTO table_name (value) VALUES (:value)
|
|
||||||
```
|
|
||||||
|
|
@ -5,44 +5,57 @@ created: Friday, December 27, 2024
|
||||||
|
|
||||||
# Audio file formats
|
# Audio file formats
|
||||||
|
|
||||||
## CD
|
## CD quality
|
||||||
|
|
||||||
- CDs store audio in uncompressed PCM (Pulse Code Modulation) format
|
We can use CD's as the digital gold standard as the best digital quality
|
||||||
- They have a sampling rate of 44.1kHz
|
available (to consumers).
|
||||||
- In two channels for stereo
|
|
||||||
|
|
||||||
## WAV: Waveform Audio File Format
|
CDs store audio in uncompressed PCM (Pulse Code Modulation) format.
|
||||||
|
|
||||||
|
They have a sampling rate of 44.1kHz, which is done in two channels to enable
|
||||||
|
stereo.
|
||||||
|
|
||||||
|
## What lossy formats entail
|
||||||
|
|
||||||
|
A conversion to MP3 from, for example, a CD source is always a one-way process
|
||||||
|
and is not reversible. Once information is discarded in the compression process,
|
||||||
|
it cannot be retrieved.
|
||||||
|
|
||||||
|
This is obviously in contrast to lossless methods like FLAC where the original
|
||||||
|
CD audio can always be reconstructed.
|
||||||
|
|
||||||
|
It follows from the above that if you repeatedly encode a CD source to MP3, it
|
||||||
|
will deteriorate in quality since more data is being removed each time.
|
||||||
|
|
||||||
|
## Major audio formats
|
||||||
|
|
||||||
|
### WAV (Waveform Audio File Format)
|
||||||
|
|
||||||
- CD-quality encoding with no compression
|
- CD-quality encoding with no compression
|
||||||
- Bit-for-bit identical to the CD source
|
- Bit-for-bit identical to the CD source
|
||||||
- Historically developed for Windows machines but can play on all operating
|
- Historically developed for Windows machines but can play on all operating
|
||||||
systems
|
systems
|
||||||
|
|
||||||
## FLAC: Free Lossless Audio Codec
|
### FLAC (Free Lossless Audio Codec)
|
||||||
|
|
||||||
- Basically the same as WAV but in a (losslessly) compressed format
|
- Basically the same as WAV but in a (losslessly) compressed format
|
||||||
- The difference between a novel in a text file (WAV) and as a zipped file
|
- The difference between a novel in a text file (WAV) and as a zipped file
|
||||||
|
|
||||||
## MP3: MPEG-1 Audio Layer MP3
|
### MP3 (MPEG-1 Audio Layer MP3)
|
||||||
|
|
||||||
- Lossy format.
|
- Lossy format.
|
||||||
- When a WAV file (or other lossless format) is converted to MP3 a Fast Fourier
|
- When a WAV file (or other lossless format) is converted to MP3 a Fast Fourier
|
||||||
Transform analysis is performed to determine the frequency of certain sounds.
|
Transform analysis is performed to determine the frequency of certain sounds
|
||||||
- This is used by the encoder to decide which parts of the sound are
|
- This is used by the encoder to decide which parts of the sound are
|
||||||
imperceptible and thus which can be discarded to reduce the file size. This is
|
imperceptible and thus which can be discarded to reduce the file size. This is
|
||||||
done through the application of psycho-acoustic models.
|
done through the application of psycho-acoustic models.
|
||||||
- The remaining data is then compressed
|
- The remaining data is then compressed
|
||||||
- Examples of the data reduction applied:
|
- Examples of the data reduction applied:
|
||||||
|
|
||||||
- Removing frequencies that humans cannot hear
|
- Removing frequencies that humans cannot hear
|
||||||
- Removing quieter sounds that are masked by louder sounds
|
- Removing quieter sounds that are masked by louder sounds
|
||||||
- Combining similar frequencies
|
- Combining similar frequencies
|
||||||
- Reducing stero information where it is less noticable
|
- Reducing stero information where it is less noticable
|
||||||
- A conversion to MP3 from, for example, a CD source is always a one-way process
|
|
||||||
and is not reversible. Once information is discarded in the compression
|
|
||||||
process it cannot be retrieved. This is obviously in contrast to lossless
|
|
||||||
methods like FLAC where the original CD audio can always be reconstructed.
|
|
||||||
- It follows from the above that if you repeatedly encode a CD source to MP3, it
|
|
||||||
will deteriorate in quality since more data is being removed each time.
|
|
||||||
|
|
||||||
## OGG: Ogg Vorbis
|
## OGG: Ogg Vorbis
|
||||||
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
---
|
||||||
|
tags: [sound, binary, analogue]
|
||||||
|
created: Friday, December 27, 2024
|
||||||
|
---
|
||||||
|
|
||||||
|
# Binary encoding of sound
|
||||||
|
|
||||||
|
Sound is a change in air pressure.
|
||||||
|
|
||||||
|
To record sound, we convert the change in air pressure into an electrical signal
|
||||||
|
by means of a microphone. Effectively, the same natural waveform is converted
|
||||||
|
from one medium (the vibration of air molecules) into another medium (electrical
|
||||||
|
charge in a field) whilst retaining the same morphology. See
|
||||||
|
[Recording and processing sound]().
|
||||||
|
|
||||||
|
The resulting electrical signal is analogue: it has a continuous and variable
|
||||||
|
frequency and amplitude and thus can have any value at any given moment.
|
||||||
|
|
||||||
|
To encode this information digitally we need to make the continuous analogue
|
||||||
|
single discrete, so that it can represented with a finite set of symbols (bits).
|
||||||
|
|
||||||
|
This process is known as **quantization** and consists in sampling the analogue
|
||||||
|
waveform. This means taking a measurement of it at different points in time -
|
||||||
|
each second.
|
||||||
|
|
||||||
|
CDs sample the audio source at a rate of 44.1 kHz: 44, 100 measurements of the
|
||||||
|
signal per second.
|
||||||
|
|
||||||
|
The measurements are then stored in a digital format: bits. The amount of bits
|
||||||
|
used to record the measurement is the **bit-depth**. Each measurement is rounded
|
||||||
|
to the nearest available digital value. CDs have a depth of 16 bits. Thus each
|
||||||
|
measurement can be one of $16^2 = 65,536$ possible values.
|
||||||
|
|
||||||
|
With sampling at a given bit-depth established, the **bitrate** can be derived.
|
||||||
|
|
||||||
|
This is the sampling rate (number of measurements per second) divided by the
|
||||||
|
number of bits per sample (bit-depth), multiplied by the number of channels.
|
||||||
|
|
||||||
|
Thus for stereo CDs this is:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(44100 / 16 ) \middot 2 = 1411200
|
||||||
|
$$
|
||||||
|
|
||||||
|
Or 1.4 Mb/s
|
||||||
|
|
||||||
|
> Even with a high bitrate (as with CDs) the process still necessarily involves
|
||||||
|
> a loss of information when converting sound from analogue to digital. However,
|
||||||
|
> given a high enough value for the sampling rate and bit-depth, the differences
|
||||||
|
> are imperceptible to the human ear.
|
||||||
59
neuron/8f51653f-9574-4f79-81a8-1f2ecc0ba592/SQLite.md
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
---
|
||||||
|
tags: [databases, SQL, SQLite]
|
||||||
|
created: Wednesday, November 13, 2024
|
||||||
|
---
|
||||||
|
|
||||||
|
# SQLite
|
||||||
|
|
||||||
|
## Enabling foreign key constraints
|
||||||
|
|
||||||
|
Foreign key constraints are not enabled by default - it is very permissive. You
|
||||||
|
must manually turn them on, as part of the connection process:
|
||||||
|
|
||||||
|
```py
|
||||||
|
connection = sqlite3.connect("my_database.db")
|
||||||
|
connection.execute("PRAGMA foreign_keys = ON")
|
||||||
|
```
|
||||||
|
|
||||||
|
## INSERT OR IGNORE INTO
|
||||||
|
|
||||||
|
If table has a `UNIQUE` constraint on a field, insert if it is unique otherwise
|
||||||
|
skip without throwing a constraint error.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
INSERT OR IGNORE INTO table_name (value) VALUES (:value)
|
||||||
|
```
|
||||||
|
|
||||||
|
## exec and fetchall
|
||||||
|
|
||||||
|
For `CREATE`, `INSERT`, `UPDATE`, `DELETE` operations it is sufficient to simply
|
||||||
|
use `execute` to carry out the operations:
|
||||||
|
|
||||||
|
```py
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute(sql)
|
||||||
|
```
|
||||||
|
|
||||||
|
For `SELECT` operations, you must add a return statement that uses `fetchall`:
|
||||||
|
|
||||||
|
```py
|
||||||
|
sql = "SELECT * FROM table"
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute(sql)
|
||||||
|
return cursor.fetchall()
|
||||||
|
```
|
||||||
|
|
||||||
|
## SELECT response data type
|
||||||
|
|
||||||
|
A `SELECT` operation returns a [list](Lists_in_Python.md) of
|
||||||
|
[tuples](Tuples_in_Python.md) where each entry in the tuple is a returned field.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```py
|
||||||
|
entries_sql = "SELECT title, size FROM entries"
|
||||||
|
|
||||||
|
entries_response = cursor.execute(entries_sql)
|
||||||
|
print(cursor.fetchall())
|
||||||
|
# [('Lorem ipsum', 127), ('Dolar sit', 4231)]
|
||||||
|
```
|
||||||
|
|
@ -63,6 +63,35 @@ We could then use it thus:
|
||||||
def parse_articles() -> list[ArticleInfo]:
|
def parse_articles() -> list[ArticleInfo]:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Explicit type construction
|
||||||
|
|
||||||
|
Sometimes, simply asserting that custom type will be returned by a function is
|
||||||
|
not sufficient to pass the type checks. In these cases you need to explicitly
|
||||||
|
construct the type within the function.
|
||||||
|
|
||||||
|
For example this generates an error as Python sees the `tags` type as
|
||||||
|
`[Dictionary]`, even though it matches the type:
|
||||||
|
|
||||||
|
```python
|
||||||
|
class IGraphNode(TypedDict):
|
||||||
|
id: str
|
||||||
|
type: str
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```py
|
||||||
|
tags = [{"id": f"#{tag[0]}", "type": "tag"} for tag in tags]
|
||||||
|
```
|
||||||
|
|
||||||
|
So you have to explicitly generate the type like this:
|
||||||
|
|
||||||
|
```python
|
||||||
|
tags = [IGraphNode(id=f"#{tag[0]}", type="tag") for tag in tags]
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you will be able to type the return of the function as
|
||||||
|
`-> list[IGraphNode]`
|
||||||
|
|
||||||
## Optional types
|
## Optional types
|
||||||
|
|
||||||
`Optional` can be used to indicate that a variable can be `None` or the
|
`Optional` can be used to indicate that a variable can be `None` or the
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
id: mjia
|
|
||||||
tags: [python, JSON]
|
tags: [python, JSON]
|
||||||
created: Tuesday, June 25, 2024
|
created: Tuesday, June 25, 2024
|
||||||
---
|
---
|
||||||
|
|
@ -20,8 +19,13 @@ Will error if the input string is not properly formatted JSON. This will be
|
||||||
Take a JSON-formatted dictionary and convert it into a string. The reverse of
|
Take a JSON-formatted dictionary and convert it into a string. The reverse of
|
||||||
`json.loads()` and equivalent to `JSON.stringify()` in JavaScript.
|
`json.loads()` and equivalent to `JSON.stringify()` in JavaScript.
|
||||||
|
|
||||||
## JSON errors
|
## `json.dump()`
|
||||||
|
|
||||||
The `.loads()` and `.parse()` methods will throw an error if the input string is
|
Not to be confused with the above. Output a Python dictionary as JSON, for
|
||||||
|
instance to create a `.json` file:
|
||||||
|
|
||||||
## Related notes
|
```py
|
||||||
|
data = { "key": "value"}
|
||||||
|
with open("some/directory/output.json", "w") as f:
|
||||||
|
json.dump(data, f, indent=4)
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
This is your new *vault*.
|
||||||
|
|
||||||
|
Make a note of something, [[create a link]], or try [the Importer](https://help.obsidian.md/Plugins/Importer)!
|
||||||
|
|
||||||
|
When you're ready, delete this note and make the vault your own.
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
This is your new *vault*.
|
||||||
|
|
||||||
|
Make a note of something, [[create a link]], or try [the Importer](https://help.obsidian.md/Plugins/Importer)!
|
||||||
|
|
||||||
|
When you're ready, delete this note and make the vault your own.
|
||||||
|
Before Width: | Height: | Size: 664 B After Width: | Height: | Size: 664 B |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
|
@ -13,14 +13,17 @@ computer science.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
**Build ID:** 3cd71ed3-2c64-460c-92b8-94889befa1fe
|
**Build ID:** 8f51653f-9574-4f79-81a8-1f2ecc0ba592
|
||||||
|
|
||||||
**Published:** Fri 27 Dec 2024 14:21:54
|
**Published:** Wed 01 Jan 2025 15:57:54
|
||||||
|
|
||||||
### Recent edits
|
### Recent edits
|
||||||
|
|
||||||
- [[Audio_file_formats]]
|
|
||||||
- [[Binary_encoding_of_sound]]
|
- [[Binary_encoding_of_sound]]
|
||||||
|
- [[Audio_file_formats]]
|
||||||
|
- [[Type_hinting]]
|
||||||
|
- [[Working_with_JSON_in_Python]]
|
||||||
|
- [[SQLite]]
|
||||||
- [[a4601796_trapdoor_functions]]
|
- [[a4601796_trapdoor_functions]]
|
||||||
- [[bbdcb54f_public_key_cryptography]]
|
- [[bbdcb54f_public_key_cryptography]]
|
||||||
- [[Dynamic_and_static_websites]]
|
- [[Dynamic_and_static_websites]]
|
||||||
|
|
@ -28,9 +31,6 @@ computer science.
|
||||||
- [[Architecture_of_the_World_Wide_Web]]
|
- [[Architecture_of_the_World_Wide_Web]]
|
||||||
- [[Network_packet_analysis_tools]]
|
- [[Network_packet_analysis_tools]]
|
||||||
- [[What_can_the_ISP_see]]
|
- [[What_can_the_ISP_see]]
|
||||||
- [[HTTPS]]
|
|
||||||
- [[Bauman_quote]]
|
|
||||||
- [[fbbfbc32-political-accommodation-inveigelment-surveillance-capitalism]]
|
|
||||||
|
|
||||||
|
|
||||||
### All notes (511)
|
### All notes (511)
|
||||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 295 KiB After Width: | Height: | Size: 295 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 145 KiB |
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 289 KiB After Width: | Height: | Size: 289 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 6.9 MiB After Width: | Height: | Size: 6.9 MiB |
|
Before Width: | Height: | Size: 224 KiB After Width: | Height: | Size: 224 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 312 KiB After Width: | Height: | Size: 312 KiB |
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 724 KiB After Width: | Height: | Size: 724 KiB |
|
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 198 KiB |
|
Before Width: | Height: | Size: 232 KiB After Width: | Height: | Size: 232 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 3.6 MiB After Width: | Height: | Size: 3.6 MiB |
|
Before Width: | Height: | Size: 204 KiB After Width: | Height: | Size: 204 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 165 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 9 KiB After Width: | Height: | Size: 9 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 808 KiB After Width: | Height: | Size: 808 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 470 KiB After Width: | Height: | Size: 470 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 201 KiB After Width: | Height: | Size: 201 KiB |
|
Before Width: | Height: | Size: 175 KiB After Width: | Height: | Size: 175 KiB |
|
Before Width: | Height: | Size: 299 KiB After Width: | Height: | Size: 299 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 213 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 155 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 848 KiB After Width: | Height: | Size: 848 KiB |
|
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 171 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 157 KiB |
|
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 226 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 153 KiB After Width: | Height: | Size: 153 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 145 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 414 KiB After Width: | Height: | Size: 414 KiB |
|
Before Width: | Height: | Size: 314 KiB After Width: | Height: | Size: 314 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 174 KiB After Width: | Height: | Size: 174 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 167 KiB After Width: | Height: | Size: 167 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 150 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 140 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 123 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 374 KiB After Width: | Height: | Size: 374 KiB |
|
Before Width: | Height: | Size: 9 KiB After Width: | Height: | Size: 9 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 448 KiB After Width: | Height: | Size: 448 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 668 KiB After Width: | Height: | Size: 668 KiB |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 144 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 249 KiB After Width: | Height: | Size: 249 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 5 KiB After Width: | Height: | Size: 5 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 139 KiB |
|
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 160 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 146 KiB After Width: | Height: | Size: 146 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 425 KiB After Width: | Height: | Size: 425 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 164 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
|
@ -5,44 +5,57 @@ created: Friday, December 27, 2024
|
||||||
|
|
||||||
# Audio file formats
|
# Audio file formats
|
||||||
|
|
||||||
## CD
|
## CD quality
|
||||||
|
|
||||||
- CDs store audio in uncompressed PCM (Pulse Code Modulation) format
|
We can use CD's as the digital gold standard as the best digital quality
|
||||||
- They have a sampling rate of 44.1kHz
|
available (to consumers).
|
||||||
- In two channels for stereo
|
|
||||||
|
|
||||||
## WAV: Waveform Audio File Format
|
CDs store audio in uncompressed PCM (Pulse Code Modulation) format.
|
||||||
|
|
||||||
|
They have a sampling rate of 44.1kHz, which is done in two channels to enable
|
||||||
|
stereo.
|
||||||
|
|
||||||
|
## What lossy formats entail
|
||||||
|
|
||||||
|
A conversion to MP3 from, for example, a CD source is always a one-way process
|
||||||
|
and is not reversible. Once information is discarded in the compression process,
|
||||||
|
it cannot be retrieved.
|
||||||
|
|
||||||
|
This is obviously in contrast to lossless methods like FLAC where the original
|
||||||
|
CD audio can always be reconstructed.
|
||||||
|
|
||||||
|
It follows from the above that if you repeatedly encode a CD source to MP3, it
|
||||||
|
will deteriorate in quality since more data is being removed each time.
|
||||||
|
|
||||||
|
## Major audio formats
|
||||||
|
|
||||||
|
### WAV (Waveform Audio File Format)
|
||||||
|
|
||||||
- CD-quality encoding with no compression
|
- CD-quality encoding with no compression
|
||||||
- Bit-for-bit identical to the CD source
|
- Bit-for-bit identical to the CD source
|
||||||
- Historically developed for Windows machines but can play on all operating
|
- Historically developed for Windows machines but can play on all operating
|
||||||
systems
|
systems
|
||||||
|
|
||||||
## FLAC: Free Lossless Audio Codec
|
### FLAC (Free Lossless Audio Codec)
|
||||||
|
|
||||||
- Basically the same as WAV but in a (losslessly) compressed format
|
- Basically the same as WAV but in a (losslessly) compressed format
|
||||||
- The difference between a novel in a text file (WAV) and as a zipped file
|
- The difference between a novel in a text file (WAV) and as a zipped file
|
||||||
|
|
||||||
## MP3: MPEG-1 Audio Layer MP3
|
### MP3 (MPEG-1 Audio Layer MP3)
|
||||||
|
|
||||||
- Lossy format.
|
- Lossy format.
|
||||||
- When a WAV file (or other lossless format) is converted to MP3 a Fast Fourier
|
- When a WAV file (or other lossless format) is converted to MP3 a Fast Fourier
|
||||||
Transform analysis is performed to determine the frequency of certain sounds.
|
Transform analysis is performed to determine the frequency of certain sounds
|
||||||
- This is used by the encoder to decide which parts of the sound are
|
- This is used by the encoder to decide which parts of the sound are
|
||||||
imperceptible and thus which can be discarded to reduce the file size. This is
|
imperceptible and thus which can be discarded to reduce the file size. This is
|
||||||
done through the application of psycho-acoustic models.
|
done through the application of psycho-acoustic models.
|
||||||
- The remaining data is then compressed
|
- The remaining data is then compressed
|
||||||
- Examples of the data reduction applied:
|
- Examples of the data reduction applied:
|
||||||
|
|
||||||
- Removing frequencies that humans cannot hear
|
- Removing frequencies that humans cannot hear
|
||||||
- Removing quieter sounds that are masked by louder sounds
|
- Removing quieter sounds that are masked by louder sounds
|
||||||
- Combining similar frequencies
|
- Combining similar frequencies
|
||||||
- Reducing stero information where it is less noticable
|
- Reducing stero information where it is less noticable
|
||||||
- A conversion to MP3 from, for example, a CD source is always a one-way process
|
|
||||||
and is not reversible. Once information is discarded in the compression
|
|
||||||
process it cannot be retrieved. This is obviously in contrast to lossless
|
|
||||||
methods like FLAC where the original CD audio can always be reconstructed.
|
|
||||||
- It follows from the above that if you repeatedly encode a CD source to MP3, it
|
|
||||||
will deteriorate in quality since more data is being removed each time.
|
|
||||||
|
|
||||||
## OGG: Ogg Vorbis
|
## OGG: Ogg Vorbis
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,50 @@
|
||||||
---
|
---
|
||||||
tags: []
|
tags: [sound, binary, analogue]
|
||||||
created: Friday, December 27, 2024
|
created: Friday, December 27, 2024
|
||||||
---
|
---
|
||||||
# Binary_encoding_of_sound
|
|
||||||
|
|
||||||
|
# Binary encoding of sound
|
||||||
|
|
||||||
|
Sound is a change in air pressure.
|
||||||
|
|
||||||
|
To record sound, we convert the change in air pressure into an electrical signal
|
||||||
|
by means of a microphone. Effectively, the same natural waveform is converted
|
||||||
|
from one medium (the vibration of air molecules) into another medium (electrical
|
||||||
|
charge in a field) whilst retaining the same morphology. See
|
||||||
|
[Recording and processing sound]().
|
||||||
|
|
||||||
|
The resulting electrical signal is analogue: it has a continuous and variable
|
||||||
|
frequency and amplitude and thus can have any value at any given moment.
|
||||||
|
|
||||||
|
To encode this information digitally we need to make the continuous analogue
|
||||||
|
single discrete, so that it can represented with a finite set of symbols (bits).
|
||||||
|
|
||||||
|
This process is known as **quantization** and consists in sampling the analogue
|
||||||
|
waveform. This means taking a measurement of it at different points in time -
|
||||||
|
each second.
|
||||||
|
|
||||||
|
CDs sample the audio source at a rate of 44.1 kHz: 44, 100 measurements of the
|
||||||
|
signal per second.
|
||||||
|
|
||||||
|
The measurements are then stored in a digital format: bits. The amount of bits
|
||||||
|
used to record the measurement is the **bit-depth**. Each measurement is rounded
|
||||||
|
to the nearest available digital value. CDs have a depth of 16 bits. Thus each
|
||||||
|
measurement can be one of $16^2 = 65,536$ possible values.
|
||||||
|
|
||||||
|
With sampling at a given bit-depth established, the **bitrate** can be derived.
|
||||||
|
|
||||||
|
This is the sampling rate (number of measurements per second) divided by the
|
||||||
|
number of bits per sample (bit-depth), multiplied by the number of channels.
|
||||||
|
|
||||||
|
Thus for stereo CDs this is:
|
||||||
|
|
||||||
|
$$
|
||||||
|
(44100 / 16 ) \middot 2 = 1411200
|
||||||
|
$$
|
||||||
|
|
||||||
|
Or 1.4 Mb/s
|
||||||
|
|
||||||
|
> Even with a high bitrate (as with CDs) the process still necessarily involves
|
||||||
|
> a loss of information when converting sound from analogue to digital. However,
|
||||||
|
> given a high enough value for the sampling rate and bit-depth, the differences
|
||||||
|
> are imperceptible to the human ear.
|
||||||
|
|
|
||||||
34
zk/SQLite.md
|
|
@ -23,3 +23,37 @@ skip without throwing a constraint error.
|
||||||
```sql
|
```sql
|
||||||
INSERT OR IGNORE INTO table_name (value) VALUES (:value)
|
INSERT OR IGNORE INTO table_name (value) VALUES (:value)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## exec and fetchall
|
||||||
|
|
||||||
|
For `CREATE`, `INSERT`, `UPDATE`, `DELETE` operations it is sufficient to simply
|
||||||
|
use `execute` to carry out the operations:
|
||||||
|
|
||||||
|
```py
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute(sql)
|
||||||
|
```
|
||||||
|
|
||||||
|
For `SELECT` operations, you must add a return statement that uses `fetchall`:
|
||||||
|
|
||||||
|
```py
|
||||||
|
sql = "SELECT * FROM table"
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute(sql)
|
||||||
|
return cursor.fetchall()
|
||||||
|
```
|
||||||
|
|
||||||
|
## SELECT response data type
|
||||||
|
|
||||||
|
A `SELECT` operation returns a [list](Lists_in_Python.md) of
|
||||||
|
[tuples](Tuples_in_Python.md) where each entry in the tuple is a returned field.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```py
|
||||||
|
entries_sql = "SELECT title, size FROM entries"
|
||||||
|
|
||||||
|
entries_response = cursor.execute(entries_sql)
|
||||||
|
print(cursor.fetchall())
|
||||||
|
# [('Lorem ipsum', 127), ('Dolar sit', 4231)]
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,35 @@ We could then use it thus:
|
||||||
def parse_articles() -> list[ArticleInfo]:
|
def parse_articles() -> list[ArticleInfo]:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Explicit type construction
|
||||||
|
|
||||||
|
Sometimes, simply asserting that custom type will be returned by a function is
|
||||||
|
not sufficient to pass the type checks. In these cases you need to explicitly
|
||||||
|
construct the type within the function.
|
||||||
|
|
||||||
|
For example this generates an error as Python sees the `tags` type as
|
||||||
|
`[Dictionary]`, even though it matches the type:
|
||||||
|
|
||||||
|
```python
|
||||||
|
class IGraphNode(TypedDict):
|
||||||
|
id: str
|
||||||
|
type: str
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```py
|
||||||
|
tags = [{"id": f"#{tag[0]}", "type": "tag"} for tag in tags]
|
||||||
|
```
|
||||||
|
|
||||||
|
So you have to explicitly generate the type like this:
|
||||||
|
|
||||||
|
```python
|
||||||
|
tags = [IGraphNode(id=f"#{tag[0]}", type="tag") for tag in tags]
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you will be able to type the return of the function as
|
||||||
|
`-> list[IGraphNode]`
|
||||||
|
|
||||||
## Optional types
|
## Optional types
|
||||||
|
|
||||||
`Optional` can be used to indicate that a variable can be `None` or the
|
`Optional` can be used to indicate that a variable can be `None` or the
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
id: mjia
|
|
||||||
tags: [python, JSON]
|
tags: [python, JSON]
|
||||||
created: Tuesday, June 25, 2024
|
created: Tuesday, June 25, 2024
|
||||||
---
|
---
|
||||||
|
|
@ -20,8 +19,13 @@ Will error if the input string is not properly formatted JSON. This will be
|
||||||
Take a JSON-formatted dictionary and convert it into a string. The reverse of
|
Take a JSON-formatted dictionary and convert it into a string. The reverse of
|
||||||
`json.loads()` and equivalent to `JSON.stringify()` in JavaScript.
|
`json.loads()` and equivalent to `JSON.stringify()` in JavaScript.
|
||||||
|
|
||||||
## JSON errors
|
## `json.dump()`
|
||||||
|
|
||||||
The `.loads()` and `.parse()` methods will throw an error if the input string is
|
Not to be confused with the above. Output a Python dictionary as JSON, for
|
||||||
|
instance to create a `.json` file:
|
||||||
|
|
||||||
## Related notes
|
```py
|
||||||
|
data = { "key": "value"}
|
||||||
|
with open("some/directory/output.json", "w") as f:
|
||||||
|
json.dump(data, f, indent=4)
|
||||||
|
```
|
||||||
|
|
|
||||||
5
zk/dfsdfdf/Welcome.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
This is your new *vault*.
|
||||||
|
|
||||||
|
Make a note of something, [[create a link]], or try [the Importer](https://help.obsidian.md/Plugins/Importer)!
|
||||||
|
|
||||||
|
When you're ready, delete this note and make the vault your own.
|
||||||
5
zk/eolas testg/Welcome.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
This is your new *vault*.
|
||||||
|
|
||||||
|
Make a note of something, [[create a link]], or try [the Importer](https://help.obsidian.md/Plugins/Importer)!
|
||||||
|
|
||||||
|
When you're ready, delete this note and make the vault your own.
|
||||||