This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-01-05 12:56:15

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Easy sound based file conversion

This is a little project I'd love to try with Scratch, I have no idea how effective it would be, but I thought some of you guys might like to take part.

I've read somewhere that a person created a way to share files between two computers using a speaker and a mic, and sound pulses to represent data bits!

Seeing as Scratch has sound input and output features  It would totally be possible, and seeing as most scratchers will have a computer mic and computer speakers (they're cheap to buy) it would be something fun they could try out too!

I'm going to try (shock,horror!) to do this with an unedited version of Scratch for a change so as to open up the number of people able to join in!

So the theory here is that text or maybe even an image can be converted into different bits of info, and sound can be used to send it from one computer to another.

Firstly, the file conversion could be done using binary as that would mean only two types of sound are needed, though the conversion from something like, say, text into binary with Scratch might be quite ineficcient. Ascii might be an option as that would cover characters in most text files, though not the specialist characters found in images. This would need more than two sounds though.

Seeing as pitch cannot be detected by ordinary Scratch (I lament), The only two options we really have are sound length and sound volume to work with.

Finally the microphone picking the data up needs to be connected to a project that can either pick up volume, measure tone length or both. Tone length is less succeptable to ambient noise but different volumes can be used to transmit data much faster as the length or up to 100 pieces of data could be sent in the same tone length.

Discuss!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#2 2011-01-05 13:48:58

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Easy sound based file conversion

Since tone length means increasing or decreasing the amount of time, that would mean that the difference would have to be great enough for the receiving project to interpret it and decode its length (which, again, needs some form of delaying and timing). That means at least 0.3 seconds for the quick tone and (counting an interval of about .3 seconds) a minimum of 0.6 for the long tone. A string of text the length of "hello" (not case sensitive) could mean about 15 seconds!!!

Volume is overall the best option I guess. using .1 second impulses, the volume would vary from 30 (or even 0!) to 100, the difference being the boolean "loud?" or not "loud?" to speed up the recognition (only slightly, but could reduce errors).

The same string "hello" would then be of only 3 seconds. A considerable difference.

To solve the surround sounds problem, and even the mike volume, you could include a volume test calibration system.

What do you think?  smile

Last edited by LS97 (2011-01-05 13:49:14)

Offline

 

#3 2011-01-05 15:49:45

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

I like the idea!
You could always put a 3.5mm jack plug in the speaker out of the first and the mic in of the second to eliminate the ambient noise completely  tongue  Last resort there though as it spoils watching it work a little.

Volume is good, I agree it speeds things up though it is waaaay less accurate, it's like comparing analogue to digital  tongue

Maybe a mixture is the answer. For example, although there are 100 possible volumes, the sound levels can change how well it can tell when one volume is different to the next. Assuming we can get away  with 5 levels as a safety, we'd get 20 possible characters per tone, then two slightly different length tones could let us still transmit a lot of data and gain some accuracy without making two tones too far apart in duration.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#4 2011-01-05 15:56:41

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

Maybe a "wait until tone is played, then adjust the distance between the speaker and mic and the speaker volume until the arrow is in the green zone"

Message with an arrow that changes X position to loudness, then play a mid-volume tone that should be 50 and wait until it is 50 with say a tolerence of +-3  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#5 2011-01-05 16:49:03

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

So assuming we take on the above mix of loudness and duration, with 20 characters per loundess, We can take a text file and reading each character one at a time, we can add an item to a list corresponding to loudness and duration. e.g. a could be 0101 and b 0201
up to 2001 and then we move on to 0102.

I think we should experiment with measuring sound length so that we can work out the fastest possible length of a tone (while allowing loudness to still be measured correctly) and how close together two tone durations can be without seeming the same to the program, and then work out the smallest registered silence to read between characters.

Then with volume we need to work out what volume volume "50" should be so that 100 and 0 are both achievable without a problem. Then minumum loundess difference that is registered as a difference.

I'll do some work on this tomorrow!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#6 2011-01-05 17:23:10

coupdegrace
Scratcher
Registered: 2009-12-02
Posts: 42

Re: Easy sound based file conversion

I'll help, but I can only help with "idea-ing".
My house is too loud to test these kinds of things.  sad


[CENTER]http://www.nodiatis.com/pub/11.jpg[/CENTER]

Offline

 

#7 2011-01-05 17:26:45

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

Aw, that's a shame, I have a nice quite room to myself. If you have a jack to jack cable you can still test it like that!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#8 2011-01-05 17:42:05

coupdegrace
Scratcher
Registered: 2009-12-02
Posts: 42

Re: Easy sound based file conversion

Forgive me for not knowing, but what is a "jack to jack" cable? Knowing the names for things isn't really my strength.  tongue


[CENTER]http://www.nodiatis.com/pub/11.jpg[/CENTER]

Offline

 

#9 2011-01-05 17:46:38

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

A jack plug is the standard plug you get on headphones. The one with three metal bits on one shaft seperated by lines. The standard size is 3.5mm and that will almost certainly be the plug you have on your computer for both your speakers and your microphone. If you get a jack to jack cable (a cable with a jack plug on both ends) you can plug one end into the speaker socket and the other end into a mic socket so that the sound is sent directly out one and into the other, eliminating background noise!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#10 2011-01-05 17:52:36

coupdegrace
Scratcher
Registered: 2009-12-02
Posts: 42

Re: Easy sound based file conversion

yikes
That's cool.
But I don't have that.  sad


[CENTER]http://www.nodiatis.com/pub/11.jpg[/CENTER]

Offline

 

#11 2011-01-05 17:54:23

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

Oh... I'd lend you one if it weren't for obvious problems there... I have a LOT. They're pretty cheap in any sound or computer shop though  smile  A second hand one on EBAY would probably be very very cheap


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#12 2011-01-05 17:55:25

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

Here's a nice pic!
http://www.tvcables.co.uk/images/items/3.5mm-stereo-jack-to-jack-cable-1m.jpg

and here's a link to just how cheap they can be online: link

Last edited by sparks (2011-01-05 17:56:40)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#13 2011-01-05 17:55:53

coupdegrace
Scratcher
Registered: 2009-12-02
Posts: 42

Re: Easy sound based file conversion

I'll try to get one so I can be an active member of the team.
We need a cool name for our project.
Like...
Operation SONIK.
Yeah.  big_smile


[CENTER]http://www.nodiatis.com/pub/11.jpg[/CENTER]

Offline

 

#14 2011-01-05 17:58:24

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

I didn't realise we needed a name for it, but now you mention it, it would probably help if we have something to call our finished software  tongue  Maybe leave it for now and see if a name suddenly sticks later on  smile

Btw, there's a link and a pic in the post above yours for you  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#15 2011-01-05 18:47:25

coupdegrace
Scratcher
Registered: 2009-12-02
Posts: 42

Re: Easy sound based file conversion

Also, do you need speakers for this?
Because I have a MacBook.
I have both an external and internal microphone, but I do not have external speakers.


[CENTER]http://www.nodiatis.com/pub/11.jpg[/CENTER]

Offline

 

#16 2011-01-05 18:53:47

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

hmmmm, you should have a speaker output on the back of the laptop or on the side somewhere, though I'm not sure where as I don't own one


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#17 2011-01-05 19:24:21

coupdegrace
Scratcher
Registered: 2009-12-02
Posts: 42

Re: Easy sound based file conversion

I have a headphone jack...
Pff, I'm so hardware ignorant.


[CENTER]http://www.nodiatis.com/pub/11.jpg[/CENTER]

Offline

 

#18 2011-01-05 19:41:30

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Easy sound based file conversion

Ah...the sounds of audio encoded data streaming through the air!  It brings back fond memories of modems and phone couplers.  A cool idea from a "can it be done" viewpoint  smile


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#19 2011-01-06 04:05:03

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

Oh it can be done in Scratch alright, that's not the challange, it's more of a "can it be done at a half decent speed?" that's the question  tongue  Also, I think it will work fine in a quiet environment  but again, the challange will be getting it to work in a slightly noiser one  tongue  I'm really looking forward to seeing how well we can do this  big_smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#20 2011-01-06 14:50:30

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

Having discussed this some more with a friend, he points out that as in morse code, it's a good idea to specify the most used characters to the shortest tone periods in order to speed up messaging. Unusual characters can be reserved for longer, less needed tones! So I'm going to start experimenting a bit and also, if someone could find a list of ascii characters in order of usage?


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#21 2011-01-06 14:55:46

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Easy sound based file conversion

cool. but i don't have a microphone to try it out

Offline

 

#22 2011-01-06 14:58:57

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

Really? You can buy them sooo cheap! You could still have a look for that list  tongue

It's easy to find one for letters, but all characters might be a bit harder to locate  tongue


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#23 2011-01-06 15:22:29

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

I'm running my first experiment now. Sending a sound of fixed volume (does not fade out) down jack plug to temporarily avoid ambient noise. Comparing the output value of the sound (volume changed each time by the volume block.) I will publish my results when all 100 volumes are checked  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#24 2011-01-06 15:39:00

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Easy sound based file conversion

results

Instrument: Electric piano 1 (5)
note duration: 0.5 beats
sending program: Scratch. (windows XP on desktop PC)
recieving program: Scratch (turbo speed on)(Windows 7 on a laptop)
connection type: Jack to jack cable. (1m)

Results:

volume                    maximum loudness registered.

1) ----------- 0
2) ----------- 0
3) ----------- 0
4) ----------- 0
5) ----------- 0
6) ----------- 1
7) ----------- 1
8) ----------- 1
9) ----------- 2
10) ----------- 2
11) ----------- 3
12) ----------- 3
13) ----------- 4
14) ----------- 5
15) ----------- 6
16) ----------- 6
17) ----------- 8
18) ----------- 8
19) ----------- 9
20) ----------- 10
21) ----------- 12
22) ----------- 13
23) ----------- 14
24) ----------- 15
25) ----------- 17
26) ----------- 18
27) ----------- 19
28) ----------- 21
29) ----------- 23
30) ----------- 24
31) ----------- 25
32) ----------- 28
33) ----------- 29
34) ----------- 31
35) ----------- 32
36) ----------- 35
37) ----------- 37
38) ----------- 38
39) ----------- 41
40) ----------- 43
41) ----------- 45
42) ----------- 47
43) ----------- 50
44) ----------- 53
45) ----------- 54
46) ----------- 56
47) ----------- 60
48) ----------- 62
49) ----------- 64
50) ----------- 69
51) ----------- 70
52) ----------- 74
53) ----------- 75
54) ----------- 80
55) ----------- 82
56) ----------- 85
57) ----------- 87
58) ----------- 92
59) ----------- 95
60) ----------- 96
61) ----------- 98
62) ----------- 98
63) ----------- 98
64) ----------- 99
65) ----------- 99
66) ----------- 99
67) ----------- 99
68) ----------- 99
69) ----------- 99
70) ----------- 99
71) ----------- 99
72) ----------- 99
73) ----------- 99
74) ----------- 99
75) ----------- 99
76) ----------- 99
77) ----------- 99
78) ----------- 99
79) ----------- 99
80) ----------- 99
81) ----------- 99
82) ----------- 99
83) ----------- 99
84) ----------- 99
85) ----------- 99
86) ----------- 99
87) ----------- 99
88) ----------- 99
89) ----------- 99
90) ----------- 98
91) ----------- 98
92) ----------- 98
93) ----------- 98
94) ----------- 98
95) ----------- 98
96) ----------- 98
97) ----------- 98
98) ----------- 98
99) ----------- 98
100) ----------- 98

Notes: As you can see, there is no direct correlation between output volume and percieved loudness. There appears to be a positive correlation though, of increasing distance between percieved volume against actual output volume. Nothing is detected before 5. Between 10 and 61 every note is at least one volume different to the previous note, though between 10 and 49 there are a seemingly random difference of one to 4 between volumes. After that, 50 to 61 have between 1 and 6 between volumes.

I have not repeated the test on these or any other computers. 10 to 61 seem to me the safest part of the Scratch volume to work with, with a difference of 4 between loudnesses to allow for difference in volume. (that's 25 characters per tone length.)

Please comment and try this at home!

Last edited by sparks (2011-01-06 15:56:05)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#25 2011-01-06 15:41:05

coupdegrace
Scratcher
Registered: 2009-12-02
Posts: 42

Re: Easy sound based file conversion

So we can only get up to 98... skipping a bunch of numbers.


[CENTER]http://www.nodiatis.com/pub/11.jpg[/CENTER]

Offline

 

Board footer