From: Svjatoslav Agejenko Date: Thu, 31 Jul 2025 00:12:02 +0000 (+0300) Subject: Describe data <-> audio CODEC X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=5829e2e7a2a4db757a59b184de76df98f5765980;p=qbasicapps.git Describe data <-> audio CODEC --- diff --git a/2D GFX/Fractals/index.html b/2D GFX/Fractals/index.html index 14c08e3..9002ff2 100644 --- a/2D GFX/Fractals/index.html +++ b/2D GFX/Fractals/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Fractals @@ -210,11 +210,11 @@

Table of Contents

@@ -236,8 +236,8 @@ -
-

1. Fractal circles

+
+

1. Fractal circles

This QBasic program generates a visually captivating spiral fractal @@ -247,7 +247,7 @@ geometry, recursive programming, and graphical design.

-
+

fractal%20circles.png

@@ -266,8 +266,8 @@ indefinitely.
-
-

2. Fractal circles animated

+
+

2. Fractal circles animated

This QBasic program creates an animated fractal composed of circles, @@ -287,29 +287,29 @@ system to control the animation's progression.

-
-

3. Fractal of squares

+
+

3. Fractal of squares

This QBasic program generates and displays a fractal pattern composed of squares.

-
+

fractal%20squares,%201.png

-
+

fractal%20squares,%202.png

-
-

4. Fractal of squares animated

+
+

4. Fractal of squares animated

This QBasic program generates an animated fractal pattern composed of @@ -331,8 +331,8 @@ resulting in a dynamic and ever-changing geometric pattern.

-
-

5. Fractal of trees

+
+

5. Fractal of trees

QBasic program that generates a visually appealing fractal tree @@ -355,7 +355,7 @@ resembles a tree, with branches that grow and change over time.

-

Created: 2025-07-30 ke 08:54

+

Created: 2025-07-30 ke 12:27

Validate

diff --git a/2D GFX/Spirals/index.html b/2D GFX/Spirals/index.html index 3508025..191b6f8 100644 --- a/2D GFX/Spirals/index.html +++ b/2D GFX/Spirals/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Spiral series @@ -210,12 +210,12 @@

Table of Contents

@@ -236,11 +236,11 @@ } -
-

1. Spiral with increasing density

+
+

1. Spiral with increasing density

-
+

spiral.png

@@ -320,11 +320,11 @@ userInput$ = INPUT$(1)
-
-

2. Spiral with varying height

+
+

2. Spiral with varying height

-
+

spiral, 2.png

@@ -391,11 +391,11 @@ a$ = INPUT$(1)
-
-

3. Shaded spiral

+
+

3. Shaded spiral

-
+

spiral, 3.png

@@ -497,8 +497,8 @@ a$ = INPUT$(1)
-
-

4. Sphere forming spiral

+
+

4. Sphere forming spiral

Similar to previous spiral, Line segments are connected between the @@ -507,7 +507,7 @@ multiple linked spherical shapes. Initially point cloud in shown:

-
+

spiral, 4, 1.png

@@ -517,7 +517,7 @@ In the next step, points are connected using lines:

-
+

spiral, 4, 2.png

@@ -622,11 +622,11 @@ a$ = INPUT$(1)
-
-

5. Textured spherical spiral

+
+

5. Textured spherical spiral

-
+

spiral, 5.png

@@ -749,11 +749,11 @@ a$ = INPUT$(1)
-
-

6. Textured and shaded spherical spiral

+
+

6. Textured and shaded spherical spiral

-
+

spiral, 6.png

@@ -937,7 +937,7 @@ yStep2 = (oppositePointY2 - oppositePointY1) / stepCount
-

Created: 2025-07-30 ke 08:54

+

Created: 2025-07-30 ke 12:27

Validate

diff --git a/2D GFX/Textures/index.html b/2D GFX/Textures/index.html index 913d1b4..850d28f 100644 --- a/2D GFX/Textures/index.html +++ b/2D GFX/Textures/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Algorithmic textures @@ -210,11 +210,11 @@

Table of Contents

@@ -233,8 +233,8 @@ } -
-

1. Circular waves

+
+

1. Circular waves

This QBasic program creates visually captivating circular wave @@ -313,8 +313,8 @@ algorithms can produce intricate and visually appealing results.

-
-

2. Diamond square clouds

+
+

2. Diamond square clouds

This QBasic program demonstrates the Diamond-Square algorithm, a @@ -429,8 +429,8 @@ WAITa$ = INPUT$(1)

-
-

3. Old paper

+
+

3. Old paper

This QBasic program generates a procedural texture that simulates the @@ -527,8 +527,8 @@ inputKey$ = INPUT$(1)

-
-

4. Wood

+
+

4. Wood

This QBasic program creates a visually appealing simulation of a wood @@ -622,8 +622,8 @@ exitKey$ = INPUT$(1)

-
-

5. Yellow flame

+
+

5. Yellow flame

"Yellow Flame" is a visually captivating program written in QBasic @@ -702,7 +702,7 @@ userInput$ = INPUT$(1)

-

Created: 2025-07-30 ke 08:54

+

Created: 2025-07-30 ke 12:27

Validate

diff --git a/3D GFX/3D Synthezier/doc/index.html b/3D GFX/3D Synthezier/doc/index.html index 1e0b353..2042d46 100644 --- a/3D GFX/3D Synthezier/doc/index.html +++ b/3D GFX/3D Synthezier/doc/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + 3D Synthezier @@ -1103,39 +1103,39 @@ hsAddReviewPanels();

Table of Contents

@@ -1157,8 +1157,8 @@ hsAddReviewPanels(); -
-

1. Operating principle

+
+

1. Operating principle

Parses scene definition language and creates 3D world based on @@ -1221,60 +1221,60 @@ They were produced by importing generated -

1.1. Rectangular city

+
+

1.1. Rectangular city

-
+

rectangular city, 1.jpeg

-
+

rectangular city, 2.jpeg

-
+

rectangular city, 3.jpeg

-
-

1.2. Hexagonal city

+
+

1.2. Hexagonal city

-
+

hexagonal city, 1.jpeg

-
+

hexagonal city, 2.jpeg

-
+

hexagonal city, 3.jpeg

-
-

2. Scene description language

+
+

2. Scene description language

See also examples.

-
-

2.1. here

+
+

2.1. here

 here
@@ -1285,8 +1285,8 @@ defines new segment
 

-
-

2.2. p

+
+

2.2. p

 p  x y z
@@ -1297,8 +1297,8 @@ defines new point
 

-
-

2.3. f

+
+

2.3. f

 f  p1 p2 p3 p4
@@ -1309,8 +1309,8 @@ defines new polygon,  p4  may be unused
 

-
-

2.4. warn

+
+

2.4. warn

 warn  <message>
@@ -1321,8 +1321,8 @@ displays warning message, and wait for key
 

-
-

2.5. end

+
+

2.5. end

 end
@@ -1333,8 +1333,8 @@ terminates parser
 

-
-

2.6. mtl

+
+

2.6. mtl

 mtl  material
@@ -1345,8 +1345,8 @@ selects material
 

-
-

2.7. mtlrnd

+
+

2.7. mtlrnd

 mtlrnd  material ...
@@ -1357,8 +1357,8 @@ selects random material from list
 

-
-

2.8. obj

+
+

2.8. obj

 obj  object xz45 xy20 x+3 y*2
@@ -1373,14 +1373,14 @@ directly from file, and not chached, to allow loading of greater than
 

-
+

rotation.png

-
-

2.9. rnd

+
+

2.9. rnd

 rnd  p^1^2^3 p^7^2^1
@@ -1391,8 +1391,8 @@ select random command to execute, ^ will be converted to spaces.
 

-
-

2.10. #

+
+

2.10. #

 # whatever text
@@ -1403,8 +1403,8 @@ comment
 

-
-

2.11. out

+
+

2.11. out

 out  file
@@ -1415,8 +1415,8 @@ specify output file name, must be first command
 

-
-

2.12. set

+
+

2.12. set

 set  variable  contents
@@ -1428,8 +1428,8 @@ string. max variables is 100. first is 0.
 

-
-

2.13. variables usage

+
+

2.13. variables usage

 anycommand %1 anything
@@ -1440,8 +1440,8 @@ inserts variable 1 contents info line
 

-
-

2.14. cmp

+
+

2.14. cmp

 cmp  flag string1 string2
@@ -1452,8 +1452,8 @@ compares strings, and inserts TRUE to flag, if they are equal, else inserts FALS
 

-
-

2.15. ?

+
+

2.15. ?

 ?flag anycommand
@@ -1468,8 +1468,8 @@ exapmle: ?3 obj car z*2 xy45
 

-
-

2.16. dum

+
+

2.16. dum

 dum
@@ -1482,16 +1482,16 @@ dummy function, does notheing
 
-
-

3. Installation

+
+

3. Installation

Edit bin/3dparse.bas file and update include path in there.

-
-

3.1. System requirements

+
+

3.1. System requirements

@@ -1522,8 +1522,8 @@ Edit bin/3dparse.bas file and update include path in there. -
-

3.2. Directory layout

+
+

3.2. Directory layout

bin
@@ -1540,8 +1540,8 @@ Edit bin/3dparse.bas file and update include path in there.
-
-

4. Usage

+
+

4. Usage

Make sure you have QB binaries in your PATH. Execute @@ -1566,7 +1566,7 @@ Visualize scene with your favourite renderer.

-

Created: 2025-07-30 ke 08:55

+

Created: 2025-07-30 ke 12:28

Validate

diff --git a/3D GFX/Miscellaneous/index.html b/3D GFX/Miscellaneous/index.html index 69acd20..5f4e084 100644 --- a/3D GFX/Miscellaneous/index.html +++ b/3D GFX/Miscellaneous/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Miscellaneous 3D graphics demos @@ -210,14 +210,14 @@

Table of Contents

@@ -238,8 +238,8 @@ } -
-

1. Rotating exclamation mark

+
+

1. Rotating exclamation mark

Wireframe 3D model of a rotating exclamation mark. @@ -258,8 +258,8 @@ Wireframe 3D model of a rotating exclamation mark.

-
-

2. 3D bouncing ball

+
+

2. 3D bouncing ball

This QBasic program creates a visually engaging 3D animation of a @@ -280,8 +280,8 @@ of early computer graphics techniques.

-
-

3. 3D text in a room

+
+

3. 3D text in a room

Wireframe 3D text hanging in a wireframe 3D room. User can look and @@ -301,8 +301,8 @@ fly around in all directions.

-
-

4. 3D bouncing cubes on grid floor

+
+

4. 3D bouncing cubes on grid floor

3D wireframe cubes bouncing on a grid floor, creating an immersive and @@ -322,8 +322,8 @@ dynamic visual effect.

-
-

5. Matrix math for rotation in 3D space

+
+

5. Matrix math for rotation in 3D space

Instead of combining simple 2D rotors, pixels in this 3D space are @@ -343,8 +343,8 @@ rotated by using matrix multiplications.

-
-

6. Maze explorer

+
+

6. Maze explorer

The Evolving 3D Maze Explorer is a QBasic program that generates and @@ -355,7 +355,7 @@ changes as they navigate through it.

-
+

Maze%20explorer.png

@@ -366,8 +366,8 @@ changes as they navigate through it.
-
-

7. Tank animation

+
+

7. Tank animation

Animated tank driving through the bridge back and forward. User can @@ -387,8 +387,8 @@ look and fly around in all directions.

-
-

8. Tiled room

+
+

8. Tiled room

Room with some tiles on the wall and on the floor. User can freely fly @@ -409,7 +409,7 @@ around.

-

Created: 2025-07-30 ke 08:55

+

Created: 2025-07-30 ke 12:29

Validate

diff --git a/3D GFX/Space/index.html b/3D GFX/Space/index.html index 7355761..e3257ab 100644 --- a/3D GFX/Space/index.html +++ b/3D GFX/Space/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Space themed 3D graphics @@ -210,10 +210,10 @@

Table of Contents

@@ -234,8 +234,8 @@ } -
-

1. Galaxy explorer

+
+

1. Galaxy explorer

This QBasic program renders a navigable 3D point cloud galaxy, @@ -245,7 +245,7 @@ galaxy with stars distributed in a spiral pattern.

-
+

Galaxy%20explorer.png

@@ -256,8 +256,8 @@ galaxy with stars distributed in a spiral pattern.
-
-

2. Rocket simulator

+
+

2. Rocket simulator

QBasic program that simulates the takeoff and flight of a rocket from @@ -279,8 +279,8 @@ observe the rocket's trajectory from various angles.

-
-

3. Stars

+
+

3. Stars

The 3D Starfield Simulation is a QBasic program that creates a @@ -320,8 +320,8 @@ based on its distance, with closer stars appearing brighter.

-
-

4. Universe explorer

+
+

4. Universe explorer

This QBasic program that simulates a navigable 3D universe. Users can @@ -358,19 +358,19 @@ limiting the number of rendered objects based on distance. -

+

1.png

-
+

2.png

-
+

3.png

@@ -382,7 +382,7 @@ limiting the number of rendered objects based on distance.
-

Created: 2025-07-30 ke 08:56

+

Created: 2025-07-30 ke 12:29

Validate

diff --git a/Math/Plotting/index.html b/Math/Plotting/index.html index ff4d269..29cc33d 100644 --- a/Math/Plotting/index.html +++ b/Math/Plotting/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Plotting @@ -210,10 +210,10 @@

Table of Contents

@@ -234,8 +234,8 @@ } -
-

1. 2D graph

+
+

1. 2D graph

The 2D Graph Plotter is a simple yet effective program written in @@ -251,7 +251,7 @@ based on a user-defined mathematical function.

-
+

2D%20graph%20plot.png

@@ -262,8 +262,8 @@ based on a user-defined mathematical function.
-
-

2. 3D graph

+
+

2. 3D graph

The 3D Heightmap Explorer is a QBasic program designed to visualize @@ -299,7 +299,7 @@ grid.

-
+

3D%20graph.png

@@ -310,8 +310,8 @@ grid.
-
-

3. Deriviative calculator

+
+

3. Deriviative calculator

This QBasic program is designed to compute and plot an arbitrary @@ -324,7 +324,7 @@ visualized.

-
+

Deriviative%20calculator.png

@@ -335,8 +335,8 @@ visualized.
-
-

4. Sine and cosine table

+
+

4. Sine and cosine table

The SIN & COS Table Generator is a QBasic program designed to visually @@ -346,7 +346,7 @@ visual representation of these fundamental trigonometric functions.

-
+

Sine%20and%20cosine%20table.png

@@ -358,7 +358,7 @@ visual representation of these fundamental trigonometric functions.
-

Created: 2025-07-30 ke 08:56

+

Created: 2025-07-30 ke 12:29

Validate

diff --git a/Math/Simulation/index.html b/Math/Simulation/index.html index d446fdb..ead8f08 100644 --- a/Math/Simulation/index.html +++ b/Math/Simulation/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Simulation @@ -210,14 +210,14 @@

Table of Contents

@@ -238,8 +238,8 @@ } -
-

1. Explosion simulator

+
+

1. Explosion simulator

This QBasic program simulates the propagation of shock waves in a gas @@ -265,7 +265,7 @@ conditions by setting velocities to zero at wall boundaries.

-
+

Explosion%20simulator.png

@@ -276,8 +276,8 @@ conditions by setting velocities to zero at wall boundaries.
-
-

2. Gravity in 2D

+
+

2. Gravity in 2D

The Gravitation Simulation program is a simple yet insightful QBasic @@ -289,7 +289,7 @@ educational tool for understanding basic orbital mechanics.

-
+

Gravity%20in%202D.png

@@ -300,8 +300,8 @@ educational tool for understanding basic orbital mechanics.
-
-

3. Gravity in 3D

+
+

3. Gravity in 3D

This QBasic program simulates the gravitational interactions between @@ -335,8 +335,8 @@ will reach stable configuration.

-
-

4. Interference

+
+

4. Interference

This QBasic program simulates the interference pattern created by two @@ -364,8 +364,8 @@ displayed as a third waveform.

-
-

5. Interferogram

+
+

5. Interferogram

This QBasic program simulates the interference pattern created by @@ -375,7 +375,7 @@ used in physics and engineering to analyze wave interactions.

-
+

Interferogram.png

@@ -386,8 +386,8 @@ used in physics and engineering to analyze wave interactions.
-
-

6. Surface tension

+
+

6. Surface tension

This QBasic program simulates the behavior of water spills and the @@ -411,7 +411,7 @@ water cell if surrounded by a high density of water cells.

-
+

Surface%20tension.png

@@ -422,8 +422,8 @@ water cell if surrounded by a high density of water cells.
-
-

7. Wave 1

+
+

7. Wave 1

This QBasic program simulates the propagation of waves across a @@ -439,7 +439,7 @@ loss.

-
+

Wave%201.png

@@ -450,8 +450,8 @@ loss.
-
-

8. Wave 2

+
+

8. Wave 2

This QBasic program simulates and visualizes the behavior of water @@ -463,7 +463,7 @@ understanding wave mechanics.

-
+

Wave%202.png

@@ -475,7 +475,7 @@ understanding wave mechanics.
-

Created: 2025-07-30 ke 08:56

+

Created: 2025-07-30 ke 12:29

Validate

diff --git a/Math/Truth table/index.html b/Math/Truth table/index.html index ca59ad0..44eb04e 100644 --- a/Math/Truth table/index.html +++ b/Math/Truth table/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Truth table calculator @@ -1103,20 +1103,20 @@ hsAddReviewPanels();

Table of Contents

@@ -1133,12 +1133,12 @@ the input variables, with the corresponding output value. Truth tables are cruci designing and understanding digital circuits, Boolean algebra, and logical expressions.

-
-

1. Implemented logical operations

+
+

1. Implemented logical operations

-
-

1.1. Equivalent ( ⇔ , 1 )

+
+

1.1. Equivalent ( ⇔ , 1 )

The equivalent operation, also known as logical biconditional, is true if and only if @@ -1196,8 +1196,8 @@ Truth Table:

-
-

1.2. Implies ( ⇒ , 2 )

+
+

1.2. Implies ( ⇒ , 2 )

An implication asserts that if the first proposition is true, the @@ -1255,8 +1255,8 @@ Truth table:

-
-

1.3. OR ( ∨ , 3 )

+
+

1.3. OR ( ∨ , 3 )

The OR operation, also known as logical disjunction, is true if at @@ -1314,8 +1314,8 @@ Truth table:

-
-

1.4. AND ( ∧ , 4 )

+
+

1.4. AND ( ∧ , 4 )

The AND operation, also known as logical conjunction, is true if and @@ -1372,8 +1372,8 @@ Truth table:

-
-

1.5. NOT ( ¬ , 5 )

+
+

1.5. NOT ( ¬ , 5 )

The NOT operation, also known as logical negation, inverts the value @@ -1414,12 +1414,12 @@ Truth Table:

-
-

2. Examples

+
+

2. Examples

-
-

2.1. Example: (A ∧ B) ∨ ¬C

+
+

2.1. Example: (A ∧ B) ∨ ¬C

@@ -1502,8 +1502,8 @@ Truth Table: -
-

2.2. Example: A ⇒ (B ∨ ¬C)

+
+

2.2. Example: A ⇒ (B ∨ ¬C)

@@ -1586,8 +1586,8 @@ Truth Table: -
-

2.3. Example: (A ⇔ B) ∧ C

+
+

2.3. Example: (A ⇔ B) ∧ C

Truth Table: @@ -1676,7 +1676,7 @@ Truth Table:

-

Created: 2025-07-30 ke 08:57

+

Created: 2025-07-30 ke 12:30

Validate

diff --git a/Miscellaneous/Mouse driver/index.html b/Miscellaneous/Mouse driver/index.html index 678471b..1beacac 100644 --- a/Miscellaneous/Mouse driver/index.html +++ b/Miscellaneous/Mouse driver/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Mouse driver for QBasic programs @@ -210,16 +210,16 @@

Table of Contents

-
-

1. Overview

+
+

1. Overview

QBasic, a popular programming language in the DOS era, lacks native @@ -230,8 +230,8 @@ workaround that allows QBasic to use mouse input.

-
-

2. High-level idea

+
+

2. High-level idea

Workaround to access mouse involves a Terminate and Stay Resident @@ -264,8 +264,8 @@ TSR keeps updating it with latest mouse state simultaneously.

-
-

3. Terminate and Stay Resident module

+
+

3. Terminate and Stay Resident module

A DOS TSR program that hooks into the system's interrupt mechanism to @@ -351,8 +351,8 @@ meanwhile.

-
-

4. QBasic demonstration program

+
+

4. QBasic demonstration program

A QBasic program that reads mouse data from the memory location @@ -362,7 +362,7 @@ clicks. -

diff --git a/Networking/Digital data over analog audio channel/INPUT.TXT b/Networking/Digital data over analog audio channel/INPUT.TXT deleted file mode 100644 index 9d26a9b..0000000 --- a/Networking/Digital data over analog audio channel/INPUT.TXT +++ /dev/null @@ -1 +0,0 @@ -This is sample encoded message! diff --git a/Networking/Digital data over analog audio channel/OUTPUT.TXT b/Networking/Digital data over analog audio channel/OUTPUT.TXT deleted file mode 100644 index 9d26a9b..0000000 --- a/Networking/Digital data over analog audio channel/OUTPUT.TXT +++ /dev/null @@ -1 +0,0 @@ -This is sample encoded message! diff --git a/Networking/Digital data over analog audio channel/SOUND.XI b/Networking/Digital data over analog audio channel/SOUND.XI deleted file mode 100644 index 60a4fcc..0000000 Binary files a/Networking/Digital data over analog audio channel/SOUND.XI and /dev/null differ diff --git a/Networking/Digital data over analog audio channel/aver.bas b/Networking/Digital data over analog audio channel/aver.bas deleted file mode 100644 index e984ed5..0000000 --- a/Networking/Digital data over analog audio channel/aver.bas +++ /dev/null @@ -1,73 +0,0 @@ -' Noise reduction -' made by Svjatoslav Agejenko -' in 2003.12 -' H-Page: svjatoslav.eu -' E-Mail: svjatoslav@svjatoslav.eu - - - -DECLARE SUB start () -DEFINT A-Y -DIM SHARED avb(1 TO 100) -DIM SHARED byte AS STRING * 1 -DIM SHARED po, pod -DIM SHARED file1$, file2$ - -start - -INPUT "average factor:", po -INPUT "divide factor:", pod - -OPEN file2$ FOR BINARY AS #1 -OPEN file1$ FOR BINARY AS #2 - -SCREEN 12 -px = 0 -1 -GET #1, , byte -c = ASC(byte) -IF c > 127 THEN c = c - 255 - -FOR a = 1 TO po - 1 -avb(a) = avb(a + 1) -NEXT a -avb(po) = c - -b = 0 -FOR a = 1 TO po -b = b + avb(a) -NEXT a - -b = b / pod -'LINE (px + 1, 0)-(px + 1, 260), 14 -LINE (px, 0)-(px, 260), 0 -PSET (px, c + 130), 12 -PSET (px, b + 130), 14 -px = px + 1 -IF px > 639 THEN px = 1 -IF b < 0 THEN b = b + 255 -IF b > 255 THEN b = 255 -byte = CHR$(b) -PUT #2, , byte -'c$ = INPUT$(1) -IF EOF(1) = 0 THEN GOTO 1 - -CLOSE #2 -CLOSE #1 - -SUB start - -IF COMMAND$ = "" THEN END -b$ = COMMAND$ -file2$ = b$ -file1$ = "" -FOR a = 1 TO LEN(b$) -c$ = RIGHT$(LEFT$(b$, a), 1) -IF c$ = "." OR c$ = " " THEN GOTO 2 -file1$ = file1$ + c$ -NEXT a -2 -file1$ = file1$ + ".awe" - -END SUB - diff --git a/Networking/Digital data over analog audio channel/index.org b/Networking/Digital data over analog audio channel/index.org deleted file mode 100755 index 83bf69b..0000000 --- a/Networking/Digital data over analog audio channel/index.org +++ /dev/null @@ -1,9 +0,0 @@ -* data in sound - -Utility to encode/decode digital information into wave sound file. -You can later record it on the tape or send it acustically or -for example over telephone line. Decoding utility -is petty noise tolerant. - - -[[file:screenshot.png]] diff --git a/Networking/Digital data over analog audio channel/msg2xi.bas b/Networking/Digital data over analog audio channel/msg2xi.bas deleted file mode 100644 index 45c1c9b..0000000 --- a/Networking/Digital data over analog audio channel/msg2xi.bas +++ /dev/null @@ -1,163 +0,0 @@ -' Utility that encodes arbitrary text message into 8 bit sound file. -' This audio can be now transferred over telephone line or recorded to magnetic tape. -' This program is free software: released under Creative Commons Zero (CC0) license -' by Svjatoslav Agejenko. -' Email: svjatoslav@svjatoslav.eu -' Homepage: http://www.svjatoslav.eu -' -' Changelog: -' 2001, Initial version -' 2024.09, Improved program readability - -DECLARE SUB StartProgram () -DECLARE SUB AddIWave () -DECLARE SUB AddOWave () -DECLARE SUB ByteToSound (soundByte AS SINGLE) - -DIM SHARED iwaveArray(1 TO 20) -DIM SHARED owaveArray(1 TO 41) -DIM SHARED iwaveData$ -DIM SHARED owaveData$ -DIM SHARED inputFile$ -DIM SHARED outputFile$ -DIM SHARED byte AS STRING * 1 - -StartProgram - -inputFile$ = "input.txt" -outputFile$ = "sound.xi" - -' Open the input and output files for binary access -OPEN inputFile$ FOR BINARY AS #2 -OPEN outputFile$ FOR BINARY AS #1 - -' Add data start header/marker to the audio file -FOR a = 1 TO 50 - AddIWave -NEXT a -AddOWave - -' Read each byte from the input file and convert it to sound -2 -GET #2, , byte -ByteToSound ASC(byte) -IF EOF(2) = 0 THEN GOTO 2 - -' Close the files after processing -CLOSE #2 -CLOSE #1 - -PRINT "Encoding of message into sound completed" - -SUB ByteToSound (soundByte AS SINGLE) -' Convert a byte to 8-bit wave sound data - soundByte = soundByte + 1 - - ' Check if the byte value is greater than 128. - ' If yes, set most significant bit to 1, otherwise 0 - IF soundByte > 128 THEN - soundByte = soundByte - 128 - AddIWave - ELSE - AddOWave - END IF - - ' Check if the byte value is greater than 64 to set next bit - IF soundByte > 64 THEN - soundByte = soundByte - 64 - AddIWave - ELSE - AddOWave - END IF - - IF soundByte > 32 THEN - soundByte = soundByte - 32 - AddIWave - ELSE - AddOWave - END IF - - IF soundByte > 16 THEN - soundByte = soundByte - 16 - AddIWave - ELSE - AddOWave - END IF - - IF soundByte > 8 THEN - soundByte = soundByte - 8 - AddIWave - ELSE - AddOWave - END IF - - IF soundByte > 4 THEN - soundByte = soundByte - 4 - AddIWave - ELSE - AddOWave - END IF - - IF soundByte > 2 THEN - soundByte = soundByte - 2 - AddIWave - ELSE - AddOWave - END IF - - ' Check if the byte value is greater than 1 - IF soundByte > 1 THEN - AddIWave - ELSE - AddOWave - END IF -END SUB - -SUB AddIWave -' Write iwaveData to the output file - PUT #1, , iwaveData$ -END SUB - -SUB AddOWave -' Write owaveData to the output file - PUT #1, , owaveData$ -END SUB - -SUB StartProgram -' Initialize wave data arrays - - pi = 3.141592653999996# - - ' Generate sine wave values to represent 1 - b = 0 - FOR a = pi / 2 TO 2.5 * pi STEP (2 * pi / 20) - b = b + 1 - iwaveArray(b) = SIN(a) * 100 - IF iwaveArray(b) < 0 THEN - iwaveArray(b) = iwaveArray(b) + 255 - END IF - NEXT a - - ' Generate sine wave values to represent 0 - b = 0 - FOR a = pi / 2 TO 2.5 * pi STEP (2 * pi / 40) - b = b + 1 - owaveArray(b) = SIN(a) * 100 - IF owaveArray(b) < 0 THEN - owaveArray(b) = owaveArray(b) + 255 - END IF - NEXT a - -' Convert wave arrays to string data - - ' Convert iwaveArray to string because strings are more computationally efficient to write into output file. - FOR a = 1 TO 20 - iwaveData$ = iwaveData$ + CHR$(iwaveArray(a)) - NEXT a - - ' Convert owaveArray to string - FOR a = 1 TO 40 - owaveData$ = owaveData$ + CHR$(owaveArray(a)) - NEXT a - -END SUB diff --git a/Networking/Digital data over analog audio channel/screenshot.png b/Networking/Digital data over analog audio channel/screenshot.png deleted file mode 100755 index 87a3a0a..0000000 Binary files a/Networking/Digital data over analog audio channel/screenshot.png and /dev/null differ diff --git a/Networking/Digital data over analog audio channel/xi2msg.bas b/Networking/Digital data over analog audio channel/xi2msg.bas deleted file mode 100644 index caa0b24..0000000 --- a/Networking/Digital data over analog audio channel/xi2msg.bas +++ /dev/null @@ -1,332 +0,0 @@ -' Utility that decodes text message from 8 bit audio recording. -' This program is free software: released under Creative Commons Zero (CC0) license -' by Svjatoslav Agejenko. -' Email: svjatoslav@svjatoslav.eu -' Homepage: http://www.svjatoslav.eu -' -' Changelog: -' 2001, Initial version -' 2024 - 2025, Improved program readability -' -' Data is encoded in the audio by using frequency modulation. -' When decoding data, program locates peaks between waveforms. -' Then it calculates distance between peaks. -' Long between peak distance is interpreted as 0 bit, short distance is 1 bit. -' Bits 0 and 1 are then sequentially added into bytes and complete -' message is decoded and shown on the screen. In addition, message is written out to -' the file. -' -' Frequency modulation was chosen over amplitude modulation because -' my tests with cassette tape recorder showed that distortions affect mostly -' signal amplitude, but do not affect signal frequency that much. -' -' Data carrying audio is preceded with special header tone. Program detects header tone -' and uses it to calculate baseline signal frequency that it will use later to decode bits. -' Also header allows to mark precise data starting point. - -DEFINT A-Y -DECLARE SUB bysf (a$, d) -DECLARE SUB messa (a$) -DECLARE SUB pfo (f, t, it) -DECLARE SUB anal () -DECLARE SUB start () -DECLARE SUB iadd () -DECLARE SUB oadd () -DECLARE SUB byt (a) - -DIM SHARED file1$ -DIM SHARED file2$ - -' Contains the actual audio waveform samples -DIM SHARED audioBuffer(-100 TO 10000) -DIM SHARED bus AS STRING * 1000 -DIM SHARED bufi -DIM SHARED bg -DIM SHARED sm -DIM SHARED beg -DIM SHARED wai -DIM SHARED old2 - -' Statistical Analysis Array (contains measured peak distances) -DIM SHARED statisticalArray(1 TO 10) -DIM SHARED statl -DIM SHARED aver -DIM SHARED byte AS STRING * 1 -DIM SHARED avv - -DIM SHARED li -DIM SHARED oc -DIM SHARED px - -start -messa "Searching for beginning..." - -OPEN "output.txt" FOR BINARY AS #1 -OPEN "sound.xi" FOR BINARY AS #2 -SEEK #2, 360 - -2 -GET #2, , bus -FOR a = 1 TO 1000 - b$ = RIGHT$(LEFT$(bus, a), 1) - bufi = bufi + 1 - c = ASC(b$) - IF c > 127 THEN c = c - 255 - audioBuffer(bufi) = c -NEXT a -IF (EOF(2) = 0) AND (bufi < 8000) THEN GOTO 2 -anal -IF EOF(2) = 0 THEN GOTO 2 - -CLOSE #2 -CLOSE #1 - -SYSTEM - -SUB anal - ' Draw a vertical line to represent the buffer data - LINE (1, 170)-(200, 430), 0, BF - - FOR a = 1 TO bufi - (avv - 1) - ' Draw horizontal lines at key points - LINE (100, 170)-(100, 430), 13 - LINE (old2 - a + 100, 170)-(old2 - a + 100, 430), 11 - LINE (0, 300)-(200, 300), 13 - - ' Plot the buffer data points - FOR b = 0 TO 200 - PSET (b, audioBuffer(b + a - 101) + 300), 0 - PSET (b, audioBuffer(b + a - 100) + 300), 14 - NEXT b - - LINE (old2 - a + 100, 170)-(old2 - a + 100, 430), 0 - - ' Calculate the average value of the buffer segment - c = 0 - FOR b = a TO a + (avv - 1) - c = c + audioBuffer(b) - NEXT b - c = c / (avv / 2) - - ' Determine if we are in a high or low state - IF c > oc THEN - IF li = -1 THEN - li = 1 - pfo a + ((avv - 1) / 2 - 1), 1, oc - GOTO 3 - END IF - END IF - - IF c < oc THEN - IF li = 1 THEN - li = -1 - pfo a + ((avv - 1) / 2 - 1), 2, oc - GOTO 3 - END IF - END IF - - 3 - ' Update the current average value - oc = c - NEXT a - - ' Shift the buffer data to the left - FOR a = bufi - (avv - 2) TO bufi - audioBuffer(a - (bufi - (avv - 2)) + 1) = audioBuffer(a) - NEXT a - - ' Update the starting index of the buffer - old2 = old2 - (bufi - (avv - 2)) + 1 - bufi = avv - 1 - -END SUB - -SUB bysf (a$, d) - ' Draw a horizontal line to represent the byte data - LINE (201, 170)-(639, 430), 1, B - - IF d = 10 THEN px = 0: a$ = "": GOTO 5 - - px = px + 1 - IF px > 53 THEN - px = 1 - 5 - DIM tempr(1 TO 32000) - GET (201, 186)-(639, 430), tempr(1) - PUT (201, 170), tempr(1), PSET - LINE (201, 414)-(639, 430), 0, BF - END IF - - ' Print the byte data to the screen - LOCATE 26, 26 + px - PRINT a$ - - ' Convert the byte value to a character and write it to the output file - byte = CHR$(d) - PUT #1, , byte - -END SUB - -SUB byt (a) - - ' Draw a horizontal line to represent the bit data - LINE (410, 0)-(639, 169), 1, B - - statl = statl + 1 - IF statl > 8 THEN - statl = 1 - b = 0 - IF statisticalArray(1) = 1 THEN b = b + 128 - IF statisticalArray(2) = 1 THEN b = b + 64 - IF statisticalArray(3) = 1 THEN b = b + 32 - IF statisticalArray(4) = 1 THEN b = b + 16 - IF statisticalArray(5) = 1 THEN b = b + 8 - IF statisticalArray(6) = 1 THEN b = b + 4 - IF statisticalArray(7) = 1 THEN b = b + 2 - IF statisticalArray(8) = 1 THEN b = b + 1 - - ' Print the byte value to the screen - LOCATE 10, 69 - PRINT b - - ' Print the hexadecimal representation of the byte value - LOCATE 10, 75 - PRINT HEX$(b) - - ' Print the character representation of the byte value - LOCATE 10, 79 - c$ = CHR$(b) - - ' Replace control characters with a space - IF b = 7 OR b = 8 OR b = 10 OR b = 12 OR b = 13 THEN c$ = " " - - PRINT c$ - - bysf c$, b - - DIM tempr(1 TO 10000) - GET (410, 16)-(639, 169), tempr(1) - PUT (410, 0), tempr(1), PSET - LINE (410, 153)-(639, 169), 0, BF - END IF - - ' Print the bit value to the screen - LOCATE 10, 50 + (statl * 2) - - statisticalArray(statl) = a - - PRINT a - -END SUB - -SUB messa (a$) - ' Draw a horizontal line to represent the message data - LINE (0, 0)-(409, 169), 1, B - - DIM tempr(1 TO 20000) - - GET (0, 16)-(409, 169), tempr(1) - - PUT (0, 0), tempr(1), PSET - - LINE (0, 153)-(409, 169), 0, BF - - ' Print the message to the screen - LOCATE 10, 1 - - PRINT a$ - -END SUB - -SUB pfo (f, t, it) - IF t = 2 THEN - bg = it - - IF wai > 0 THEN wai = wai - 1 - - ' Check if we have found data start header - IF (bg - sm > 6) AND (beg = 0) THEN - beg = 1 - wai = 10 - messa "Beginning point found!" - END IF - - ' Perform statistical analysis if needed - IF (wai = 0) AND (beg = 1) THEN - IF statl = 0 THEN messa "Beginning statistical analyze" - - statl = statl + 1 - - IF statl > 10 THEN - FOR a = 1 TO 10 - aver = aver + statisticalArray(a) - NEXT a - - aver = aver * 1.5 / 10 - - beg = 2 - - statl = 1 - - messa "Statistical analyze completed!" - END IF - - ' Store the current frame index - statisticalArray(statl) = f - old2 - END IF - - ' Decode the bits if we are in the decoding state - IF beg = 2 THEN - IF f - old2 >= aver THEN - beg = 3 - - statl = 0 - - FOR a = 1 TO 8 - statisticalArray(a) = 0 - NEXT a - - GOTO 4 - END IF - END IF - - ' Decode the bits based on the current state - IF beg = 3 THEN - IF f - old2 >= aver THEN - byt 0 - ELSE - byt 1 - END IF - END IF - - 4 - - old2 = f - ELSE - sm = it - END IF -END SUB - -SUB start - - ' Set the screen mode to graphics - SCREEN 12 - - ' Initialize buffer index and other variables - bufi = 0 - - beg = 0 - - statl = 0 - - aver = 0 - - px = 0 - - avv = 7 - - li = 1 - - oc = -9999 - -END SUB \ No newline at end of file diff --git a/Networking/Digital data over analog audio/INPUT.TXT b/Networking/Digital data over analog audio/INPUT.TXT new file mode 100644 index 0000000..9d26a9b --- /dev/null +++ b/Networking/Digital data over analog audio/INPUT.TXT @@ -0,0 +1 @@ +This is sample encoded message! diff --git a/Networking/Digital data over analog audio/OUTPUT.TXT b/Networking/Digital data over analog audio/OUTPUT.TXT new file mode 100644 index 0000000..9d26a9b --- /dev/null +++ b/Networking/Digital data over analog audio/OUTPUT.TXT @@ -0,0 +1 @@ +This is sample encoded message! diff --git a/Networking/Digital data over analog audio/SOUND.XI b/Networking/Digital data over analog audio/SOUND.XI new file mode 100644 index 0000000..60a4fcc Binary files /dev/null and b/Networking/Digital data over analog audio/SOUND.XI differ diff --git a/Networking/Digital data over analog audio/aver.bas b/Networking/Digital data over analog audio/aver.bas new file mode 100644 index 0000000..950896f --- /dev/null +++ b/Networking/Digital data over analog audio/aver.bas @@ -0,0 +1,77 @@ +' Utility that reduces high frequency noise/hiss in audio file. +' In some casus it can help when recovering digital data from sound file. +' +' This program is free software: released under Creative Commons Zero (CC0) license +' by Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' 2003.12, Initial version + + +DECLARE SUB start () +DEFINT A-Y +DIM SHARED avb(1 TO 100) +DIM SHARED byte AS STRING * 1 +DIM SHARED po, pod +DIM SHARED file1$, file2$ + +start + +INPUT "average factor:", po +INPUT "divide factor:", pod + +OPEN file2$ FOR BINARY AS #1 +OPEN file1$ FOR BINARY AS #2 + +SCREEN 12 +px = 0 +1 +GET #1, , byte +c = ASC(byte) +IF c > 127 THEN c = c - 255 + +FOR a = 1 TO po - 1 +avb(a) = avb(a + 1) +NEXT a +avb(po) = c + +b = 0 +FOR a = 1 TO po +b = b + avb(a) +NEXT a + +b = b / pod +'LINE (px + 1, 0)-(px + 1, 260), 14 +LINE (px, 0)-(px, 260), 0 +PSET (px, c + 130), 12 +PSET (px, b + 130), 14 +px = px + 1 +IF px > 639 THEN px = 1 +IF b < 0 THEN b = b + 255 +IF b > 255 THEN b = 255 +byte = CHR$(b) +PUT #2, , byte +'c$ = INPUT$(1) +IF EOF(1) = 0 THEN GOTO 1 + +CLOSE #2 +CLOSE #1 + +SUB start + +IF COMMAND$ = "" THEN END +b$ = COMMAND$ +file2$ = b$ +file1$ = "" +FOR a = 1 TO LEN(b$) +c$ = RIGHT$(LEFT$(b$, a), 1) +IF c$ = "." OR c$ = " " THEN GOTO 2 +file1$ = file1$ + c$ +NEXT a +2 +file1$ = file1$ + ".awe" + +END SUB + diff --git a/Networking/Digital data over analog audio/index.html b/Networking/Digital data over analog audio/index.html new file mode 100644 index 0000000..337dacc --- /dev/null +++ b/Networking/Digital data over analog audio/index.html @@ -0,0 +1,350 @@ + + + + + + + +Data over analog audio + + + + + + +
+

Data over analog audio

+ + +
+

1. msg2xi: Text to Sound Encoder

+
+

+msg2xi is a utility designed to encode arbitrary text messages into an +8-bit sound file. This program allows users to convert digital data +into analog audio signals, making it possible to transmit text +messages over traditional analog mediums such as telephone lines or +magnetic tapes. +

+ +

+How It Works: The program reads text from an input file, processing +it byte by byte. Each byte is broken down into its constituent bits. +For each bit, a sine wave is generated. Different waveforms represent +'1's and '0's (implementing frequency modulation). The generated +waveforms are combined into a single audio file, encoding the original +text message. A special pure sinewave header tone is added to the +beginning of the audio file to mark the start of the encoded message, +facilitating synchronization during decoding. +

+ +

+Download source code: Source code +

+
+
+ +
+

2. xi2msg: Sound to Text Decoder

+
+

+The xi2msg utility is designed to decode digital information from an +audio file, specifically an 8-bit sound file. This program is part of +a suite of utilities that enable the transmission of digital data over +analog audio mediums, such as telephone lines or magnetic tapes. +

+ +

+The xi2msg utility works by analyzing the audio file to locate peaks +between waveforms. It calculates the distance between these peaks to +determine whether each segment represents a '0' or a '1' bit. This +process involves several key steps: +

+ +
+
Header Detection
The program starts by searching for a special +header tone in the audio file. This header tone marks the beginning +of the encoded message and helps synchronize the decoding process.
+ +
Peak Analysis
The utility measures the distance between peaks in +the audio waveform. Long distances between peaks are interpreted as +'0' bits, while short distances are interpreted as '1' bits.
+ +
Bit Assembly
The detected bits are sequentially assembled into +bytes. Each byte is then converted into its corresponding character.
+ +
Output
The decoded message is displayed on the screen and written +to an output file, making it accessible for further use or analysis.
+
+ +

+The program relies on frequency modulation for decoding data, which +was chosen for its resilience to amplitude distortions that can occur +during analog transmission. This makes the utility particularly +effective for decoding messages recorded on cassette tapes or +transmitted over telephone lines. +

+ + +
+

screenshot.png +

+
+ + +

+Download source code: Source code +

+
+
+ +
+

3. aver

+
+

+The aver.bas utility is designed to reduce noise in digitized audio +files by smoothing out noise peaks, which is particularly beneficial +for audio files transmitted over analog mediums like telephone lines +or magnetic tapes, where noise interference is common. +

+ +

+The program starts by asking the user for two critical factors: the +averaging factor and the divide factor. These parameters determine the +intensity of the noise reduction applied. +

+ +

+For each byte read from the input file, the program stores the last N +values (where N is the averaging factor). These values are averaged, +and the result is scaled by the divide factor. This averaging +technique helps to smooth out noise spikes in the audio data. +

+ +

+The program provides a graphical representation of the original and +smoothed audio. This allows for visual comparison of the original and +processed signals on the screen. The smoothed audio data is written to +an output file, which should have reduced noise compared to the input +file. +

+ +

+The program uses command-line input to determine the filenames for +input and output, defaulting to appending .awe to the input filename +for the output file. +

+ +

+Download source code: Source code +

+
+
+
+
+

Created: 2025-07-31 to 03:01

+

Validate

+
+ + diff --git a/Networking/Digital data over analog audio/index.org b/Networking/Digital data over analog audio/index.org new file mode 100755 index 0000000..17d1b39 --- /dev/null +++ b/Networking/Digital data over analog audio/index.org @@ -0,0 +1,92 @@ +#+TITLE: Data over analog audio +#+LANGUAGE: en +#+LATEX_HEADER: \usepackage[margin=1.0in]{geometry} +#+LATEX_HEADER: \usepackage{parskip} +#+LATEX_HEADER: \usepackage[none]{hyphenat} + +#+OPTIONS: H:20 num:20 +#+OPTIONS: author:nil + +* msg2xi: Text to Sound Encoder + +*msg2xi* is a utility designed to encode arbitrary text messages into an +8-bit sound file. This program allows users to convert digital data +into analog audio signals, making it possible to transmit text +messages over traditional analog mediums such as telephone lines or +magnetic tapes. + +*How It Works:* The program reads text from an input file, processing +it byte by byte. Each byte is broken down into its constituent bits. +For each bit, a sine wave is generated. Different waveforms represent +'1's and '0's (implementing frequency modulation). The generated +waveforms are combined into a single audio file, encoding the original +text message. A special pure sinewave header tone is added to the +beginning of the audio file to mark the start of the encoded message, +facilitating synchronization during decoding. + +Download source code: [[file:msg2xi.bas][Source code]] + +* xi2msg: Sound to Text Decoder + +The *xi2msg* utility is designed to decode digital information from an +audio file, specifically an 8-bit sound file. This program is part of +a suite of utilities that enable the transmission of digital data over +analog audio mediums, such as telephone lines or magnetic tapes. + +The *xi2msg* utility works by analyzing the audio file to locate peaks +between waveforms. It calculates the distance between these peaks to +determine whether each segment represents a '0' or a '1' bit. This +process involves several key steps: + +- Header Detection :: The program starts by searching for a special + header tone in the audio file. This header tone marks the beginning + of the encoded message and helps synchronize the decoding process. + +- Peak Analysis :: The utility measures the distance between peaks in + the audio waveform. Long distances between peaks are interpreted as + '0' bits, while short distances are interpreted as '1' bits. + +- Bit Assembly :: The detected bits are sequentially assembled into + bytes. Each byte is then converted into its corresponding character. + +- Output :: The decoded message is displayed on the screen and written + to an output file, making it accessible for further use or analysis. + +The program relies on frequency modulation for decoding data, which +was chosen for its resilience to amplitude distortions that can occur +during analog transmission. This makes the utility particularly +effective for decoding messages recorded on cassette tapes or +transmitted over telephone lines. + +[[file:screenshot.png]] + + +Download source code: [[file:xi2msg.bas][Source code]] + +* aver + +The *aver.bas* utility is designed to reduce noise in digitized audio +files by smoothing out noise peaks, which is particularly beneficial +for audio files transmitted over analog mediums like telephone lines +or magnetic tapes, where noise interference is common. + +The program starts by asking the user for two critical factors: the +averaging factor and the divide factor. These parameters determine the +intensity of the noise reduction applied. + +For each byte read from the input file, the program stores the last N +values (where N is the averaging factor). These values are averaged, +and the result is scaled by the divide factor. This averaging +technique helps to smooth out noise spikes in the audio data. + +The program provides a graphical representation of the original and +smoothed audio. This allows for visual comparison of the original and +processed signals on the screen. The smoothed audio data is written to +an output file, which should have reduced noise compared to the input +file. + +The program uses command-line input to determine the filenames for +input and output, defaulting to appending .awe to the input filename +for the output file. + +Download source code: [[file:aver.bas][Source code]] diff --git a/Networking/Digital data over analog audio/msg2xi.bas b/Networking/Digital data over analog audio/msg2xi.bas new file mode 100644 index 0000000..660304e --- /dev/null +++ b/Networking/Digital data over analog audio/msg2xi.bas @@ -0,0 +1,164 @@ +' Utility that encodes arbitrary text message into 8 bit sound file. +' This audio can be now transferred over telephone line or recorded to magnetic tape. +' +' This program is free software: released under Creative Commons Zero (CC0) license +' by Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' 2001, Initial version +' 2024.09, Improved program readability + +DECLARE SUB StartProgram () +DECLARE SUB AddIWave () +DECLARE SUB AddOWave () +DECLARE SUB ByteToSound (soundByte AS SINGLE) + +DIM SHARED iwaveArray(1 TO 20) +DIM SHARED owaveArray(1 TO 41) +DIM SHARED iwaveData$ +DIM SHARED owaveData$ +DIM SHARED inputFile$ +DIM SHARED outputFile$ +DIM SHARED byte AS STRING * 1 + +StartProgram + +inputFile$ = "input.txt" +outputFile$ = "sound.xi" + +' Open the input and output files for binary access +OPEN inputFile$ FOR BINARY AS #2 +OPEN outputFile$ FOR BINARY AS #1 + +' Add data start header/marker to the audio file +FOR a = 1 TO 50 + AddIWave +NEXT a +AddOWave + +' Read each byte from the input file and convert it to sound +2 +GET #2, , byte +ByteToSound ASC(byte) +IF EOF(2) = 0 THEN GOTO 2 + +' Close the files after processing +CLOSE #2 +CLOSE #1 + +PRINT "Encoding of message into sound completed" + +SUB ByteToSound (soundByte AS SINGLE) +' Convert a byte to 8-bit wave sound data + soundByte = soundByte + 1 + + ' Check if the byte value is greater than 128. + ' If yes, set most significant bit to 1, otherwise 0 + IF soundByte > 128 THEN + soundByte = soundByte - 128 + AddIWave + ELSE + AddOWave + END IF + + ' Check if the byte value is greater than 64 to set next bit + IF soundByte > 64 THEN + soundByte = soundByte - 64 + AddIWave + ELSE + AddOWave + END IF + + IF soundByte > 32 THEN + soundByte = soundByte - 32 + AddIWave + ELSE + AddOWave + END IF + + IF soundByte > 16 THEN + soundByte = soundByte - 16 + AddIWave + ELSE + AddOWave + END IF + + IF soundByte > 8 THEN + soundByte = soundByte - 8 + AddIWave + ELSE + AddOWave + END IF + + IF soundByte > 4 THEN + soundByte = soundByte - 4 + AddIWave + ELSE + AddOWave + END IF + + IF soundByte > 2 THEN + soundByte = soundByte - 2 + AddIWave + ELSE + AddOWave + END IF + + ' Check if the byte value is greater than 1 + IF soundByte > 1 THEN + AddIWave + ELSE + AddOWave + END IF +END SUB + +SUB AddIWave +' Write iwaveData to the output file + PUT #1, , iwaveData$ +END SUB + +SUB AddOWave +' Write owaveData to the output file + PUT #1, , owaveData$ +END SUB + +SUB StartProgram +' Initialize wave data arrays + + pi = 3.141592653999996# + + ' Generate sine wave values to represent 1 + b = 0 + FOR a = pi / 2 TO 2.5 * pi STEP (2 * pi / 20) + b = b + 1 + iwaveArray(b) = SIN(a) * 100 + IF iwaveArray(b) < 0 THEN + iwaveArray(b) = iwaveArray(b) + 255 + END IF + NEXT a + + ' Generate sine wave values to represent 0 + b = 0 + FOR a = pi / 2 TO 2.5 * pi STEP (2 * pi / 40) + b = b + 1 + owaveArray(b) = SIN(a) * 100 + IF owaveArray(b) < 0 THEN + owaveArray(b) = owaveArray(b) + 255 + END IF + NEXT a + +' Convert wave arrays to string data + + ' Convert iwaveArray to string because strings are more computationally efficient to write into output file. + FOR a = 1 TO 20 + iwaveData$ = iwaveData$ + CHR$(iwaveArray(a)) + NEXT a + + ' Convert owaveArray to string + FOR a = 1 TO 40 + owaveData$ = owaveData$ + CHR$(owaveArray(a)) + NEXT a + +END SUB diff --git a/Networking/Digital data over analog audio/screenshot.png b/Networking/Digital data over analog audio/screenshot.png new file mode 100755 index 0000000..87a3a0a Binary files /dev/null and b/Networking/Digital data over analog audio/screenshot.png differ diff --git a/Networking/Digital data over analog audio/xi2msg.bas b/Networking/Digital data over analog audio/xi2msg.bas new file mode 100644 index 0000000..bc97e9f --- /dev/null +++ b/Networking/Digital data over analog audio/xi2msg.bas @@ -0,0 +1,333 @@ +' Utility that decodes text message from 8 bit audio recording. +' +' This program is free software: released under Creative Commons Zero (CC0) license +' by Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' 2001, Initial version +' 2024 - 2025, Improved program readability +' +' Data is encoded in the audio by using frequency modulation. +' When decoding data, program locates peaks between waveforms. +' Then it calculates distance between peaks. +' Long between peak distance is interpreted as 0 bit, short distance is 1 bit. +' Bits 0 and 1 are then sequentially added into bytes and complete +' message is decoded and shown on the screen. In addition, message is written out to +' the file. +' +' Frequency modulation was chosen over amplitude modulation because +' my tests with cassette tape recorder showed that distortions affect mostly +' signal amplitude, but do not affect signal frequency that much. +' +' Data carrying audio is preceded with special header tone. Program detects header tone +' and uses it to calculate baseline signal frequency that it will use later to decode bits. +' Also header allows to mark precise data starting point. + +DEFINT A-Y +DECLARE SUB bysf (a$, d) +DECLARE SUB messa (a$) +DECLARE SUB pfo (f, t, it) +DECLARE SUB anal () +DECLARE SUB start () +DECLARE SUB iadd () +DECLARE SUB oadd () +DECLARE SUB byt (a) + +DIM SHARED file1$ +DIM SHARED file2$ + +' Contains the actual audio waveform samples +DIM SHARED audioBuffer(-100 TO 10000) +DIM SHARED bus AS STRING * 1000 +DIM SHARED bufi +DIM SHARED bg +DIM SHARED sm +DIM SHARED beg +DIM SHARED wai +DIM SHARED old2 + +' Statistical Analysis Array (contains measured peak distances) +DIM SHARED statisticalArray(1 TO 10) +DIM SHARED statl +DIM SHARED aver +DIM SHARED byte AS STRING * 1 +DIM SHARED avv + +DIM SHARED li +DIM SHARED oc +DIM SHARED px + +start +messa "Searching for beginning..." + +OPEN "output.txt" FOR BINARY AS #1 +OPEN "sound.xi" FOR BINARY AS #2 +SEEK #2, 360 + +2 +GET #2, , bus +FOR a = 1 TO 1000 + b$ = RIGHT$(LEFT$(bus, a), 1) + bufi = bufi + 1 + c = ASC(b$) + IF c > 127 THEN c = c - 255 + audioBuffer(bufi) = c +NEXT a +IF (EOF(2) = 0) AND (bufi < 8000) THEN GOTO 2 +anal +IF EOF(2) = 0 THEN GOTO 2 + +CLOSE #2 +CLOSE #1 + +SYSTEM + +SUB anal + ' Draw a vertical line to represent the buffer data + LINE (1, 170)-(200, 430), 0, BF + + FOR a = 1 TO bufi - (avv - 1) + ' Draw horizontal lines at key points + LINE (100, 170)-(100, 430), 13 + LINE (old2 - a + 100, 170)-(old2 - a + 100, 430), 11 + LINE (0, 300)-(200, 300), 13 + + ' Plot the buffer data points + FOR b = 0 TO 200 + PSET (b, audioBuffer(b + a - 101) + 300), 0 + PSET (b, audioBuffer(b + a - 100) + 300), 14 + NEXT b + + LINE (old2 - a + 100, 170)-(old2 - a + 100, 430), 0 + + ' Calculate the average value of the buffer segment + c = 0 + FOR b = a TO a + (avv - 1) + c = c + audioBuffer(b) + NEXT b + c = c / (avv / 2) + + ' Determine if we are in a high or low state + IF c > oc THEN + IF li = -1 THEN + li = 1 + pfo a + ((avv - 1) / 2 - 1), 1, oc + GOTO 3 + END IF + END IF + + IF c < oc THEN + IF li = 1 THEN + li = -1 + pfo a + ((avv - 1) / 2 - 1), 2, oc + GOTO 3 + END IF + END IF + + 3 + ' Update the current average value + oc = c + NEXT a + + ' Shift the buffer data to the left + FOR a = bufi - (avv - 2) TO bufi + audioBuffer(a - (bufi - (avv - 2)) + 1) = audioBuffer(a) + NEXT a + + ' Update the starting index of the buffer + old2 = old2 - (bufi - (avv - 2)) + 1 + bufi = avv - 1 + +END SUB + +SUB bysf (a$, d) + ' Draw a horizontal line to represent the byte data + LINE (201, 170)-(639, 430), 1, B + + IF d = 10 THEN px = 0: a$ = "": GOTO 5 + + px = px + 1 + IF px > 53 THEN + px = 1 + 5 + DIM tempr(1 TO 32000) + GET (201, 186)-(639, 430), tempr(1) + PUT (201, 170), tempr(1), PSET + LINE (201, 414)-(639, 430), 0, BF + END IF + + ' Print the byte data to the screen + LOCATE 26, 26 + px + PRINT a$ + + ' Convert the byte value to a character and write it to the output file + byte = CHR$(d) + PUT #1, , byte + +END SUB + +SUB byt (a) + + ' Draw a horizontal line to represent the bit data + LINE (410, 0)-(639, 169), 1, B + + statl = statl + 1 + IF statl > 8 THEN + statl = 1 + b = 0 + IF statisticalArray(1) = 1 THEN b = b + 128 + IF statisticalArray(2) = 1 THEN b = b + 64 + IF statisticalArray(3) = 1 THEN b = b + 32 + IF statisticalArray(4) = 1 THEN b = b + 16 + IF statisticalArray(5) = 1 THEN b = b + 8 + IF statisticalArray(6) = 1 THEN b = b + 4 + IF statisticalArray(7) = 1 THEN b = b + 2 + IF statisticalArray(8) = 1 THEN b = b + 1 + + ' Print the byte value to the screen + LOCATE 10, 69 + PRINT b + + ' Print the hexadecimal representation of the byte value + LOCATE 10, 75 + PRINT HEX$(b) + + ' Print the character representation of the byte value + LOCATE 10, 79 + c$ = CHR$(b) + + ' Replace control characters with a space + IF b = 7 OR b = 8 OR b = 10 OR b = 12 OR b = 13 THEN c$ = " " + + PRINT c$ + + bysf c$, b + + DIM tempr(1 TO 10000) + GET (410, 16)-(639, 169), tempr(1) + PUT (410, 0), tempr(1), PSET + LINE (410, 153)-(639, 169), 0, BF + END IF + + ' Print the bit value to the screen + LOCATE 10, 50 + (statl * 2) + + statisticalArray(statl) = a + + PRINT a + +END SUB + +SUB messa (a$) + ' Draw a horizontal line to represent the message data + LINE (0, 0)-(409, 169), 1, B + + DIM tempr(1 TO 20000) + + GET (0, 16)-(409, 169), tempr(1) + + PUT (0, 0), tempr(1), PSET + + LINE (0, 153)-(409, 169), 0, BF + + ' Print the message to the screen + LOCATE 10, 1 + + PRINT a$ + +END SUB + +SUB pfo (f, t, it) + IF t = 2 THEN + bg = it + + IF wai > 0 THEN wai = wai - 1 + + ' Check if we have found data start header + IF (bg - sm > 6) AND (beg = 0) THEN + beg = 1 + wai = 10 + messa "Beginning point found!" + END IF + + ' Perform statistical analysis if needed + IF (wai = 0) AND (beg = 1) THEN + IF statl = 0 THEN messa "Beginning statistical analyze" + + statl = statl + 1 + + IF statl > 10 THEN + FOR a = 1 TO 10 + aver = aver + statisticalArray(a) + NEXT a + + aver = aver * 1.5 / 10 + + beg = 2 + + statl = 1 + + messa "Statistical analyze completed!" + END IF + + ' Store the current frame index + statisticalArray(statl) = f - old2 + END IF + + ' Decode the bits if we are in the decoding state + IF beg = 2 THEN + IF f - old2 >= aver THEN + beg = 3 + + statl = 0 + + FOR a = 1 TO 8 + statisticalArray(a) = 0 + NEXT a + + GOTO 4 + END IF + END IF + + ' Decode the bits based on the current state + IF beg = 3 THEN + IF f - old2 >= aver THEN + byt 0 + ELSE + byt 1 + END IF + END IF + + 4 + + old2 = f + ELSE + sm = it + END IF +END SUB + +SUB start + + ' Set the screen mode to graphics + SCREEN 12 + + ' Initialize buffer index and other variables + bufi = 0 + + beg = 0 + + statl = 0 + + aver = 0 + + px = 0 + + avv = 7 + + li = 1 + + oc = -9999 + +END SUB \ No newline at end of file diff --git a/Tools/Update web site b/Tools/Update web site index cdb8798..acd87ee 100755 --- a/Tools/Update web site +++ b/Tools/Update web site @@ -42,6 +42,7 @@ export_org_to_html "Math/Truth table" export_org_to_html "Miscellaneous/Mouse driver" +export_org_to_html "Networking/Digital data over analog audio" # Upload project homepage to the server. rsync -avz --delete -e 'ssh -p 10006' ./ \ diff --git a/index.org b/index.org index 9666ec6..f7eb122 100644 --- a/index.org +++ b/index.org @@ -1,5 +1,5 @@ #+SETUPFILE: ~/.emacs.d/org-styles/html/darksun.theme -#+TITLE: BASIC applications collection +#+TITLE: BASIC applications collection #+LANGUAGE: en #+LATEX_HEADER: \usepackage[margin=1.0in]{geometry} #+LATEX_HEADER: \usepackage{parskip} @@ -381,7 +381,7 @@ scene is rendered frame by frame.
#+end_export -[[file:Math/Game%20of%20life%20in%203D.bas][Source code]] +Download source code: [[file:Math/Game%20of%20life%20in%203D.bas][Source code]] ** Game of life studio @@ -772,9 +772,7 @@ message. Download source code: [[file:Miscellaneous/Password%20lock/passw.bas][passw.bas]] - * Networking - ** LPT port pin control This QBasic program is designed to control the voltage on individual @@ -796,6 +794,17 @@ The program uses bit manipulation to control individual pins. Download source code: [[file:Networking/LPT%20pin%20control.bas][LPT pin control.bas]] +** Data over analog audio CODEC + +Utilities to encode digital data to sound file and back. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Networking/Digital%20data%20over%20analog%20audio/index.html][file:Networking/Digital%20data%20over%20analog%20audio/screenshot.png]] + +[[file:Networking/Digital%20data%20over%20analog%20audio/index.html][Read more]] + + ** Morse This QBasic program allows users to input text and hear it played back