Re: Dragon 32 Homecomputer Kassetten in ASCII umwandeln...
Verfasst: Donnerstag 22. August 2013, 18:09
irgendwie ist noch der Wurm drin: https://github.com/jedie/PyDragon32/com ... 49179b13d2
Seit 2002 Diskussionen rund um die Programmiersprache Python
https://www.python-forum.de/
Code: Alles auswählen
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| | * |
| | * |
| | * |
| | * |
bit 1 at 1868 in 19Samples = 2321Hz
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| | * |
| | * |
bit 0 at 1897 in 29Samples = 1520Hz
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| | * |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| | * |
| | * |
| | * |
| | * |
bit 1 at 1916 in 19Samples = 2321Hz
Code: Alles auswählen
==== go into positive sinus cycle ===============
bit 0 at 4432 in 33Samples = 1336Hz
| | * | value: 76 (3.0%)
| | * | value: 49 (5.0%)
| | * | value: 21 (12.0%)
| |* | value: 6 (42.0%)
| * | value: 3 (85.0%)
| | * | value: 11 (23.0%)
| | * | value: 29 (8.0%)
| | * | value: 57 (4.0%)
| | * | value: 85 (3.0%)
| | * | value: 85 (3.0%)
| * | | value: -125 (3.0%)
| * | | value: -113 (3.0%)
| * | | value: -94 (3.0%)
| * | | value: -77 (4.0%)
| * | | value: -63 (5.0%)
| * | | value: -49 (6.0%)
| * | | value: -36 (8.0%)
| * | | value: -22 (12.0%)
| * | | value: -14 (19.0%)
| *| | value: -7 (37.0%)
| *| | value: -5 (51.0%)
| *| | value: -5 (51.0%)
| *| | value: -7 (37.0%)
| * | | value: -14 (19.0%)
| * | | value: -21 (13.0%)
| * | | value: -34 (8.0%)
| * | | value: -46 (6.0%)
| * | | value: -60 (5.0%)
| * | | value: -74 (4.0%)
| * | | value: -90 (3.0%)
| * | | value: -110 (3.0%)
| | * | value: 126 (2.0%)
==== go into positive sinus cycle ===============
bit 0 at 4464 in 32Samples = 1378Hz
| | * | value: 112 (2.0%)
| | * | value: 93 (2.0%)
| | * | value: 76 (3.0%)
| | * | value: 62 (4.0%)
| | * | value: 49 (5.0%)
| | * | value: 35 (7.0%)
| | * | value: 21 (12.0%)
| | * | value: 13 (19.0%)
| |* | value: 6 (42.0%)
| * | value: 3 (85.0%)
| * | value: 3 (85.0%)
| |* | value: 4 (63.0%)
| | * | value: 11 (23.0%)
| | * | value: 18 (14.0%)
| | * | value: 29 (8.0%)
| | * | value: 43 (5.0%)
| | * | value: 57 (4.0%)
| | * | value: 71 (3.0%)
| | * | value: 85 (3.0%)
| | * | value: 105 (2.0%)
| | * | value: 105 (2.0%)
| * | | value: -125 (3.0%)
| * | | value: -94 (3.0%)
| * | | value: -63 (5.0%)
| * | | value: -36 (8.0%)
| * | | value: -14 (19.0%)
| *| | value: -5 (51.0%)
| *| | value: -7 (37.0%)
| * | | value: -21 (13.0%)
| * | | value: -46 (6.0%)
| * | | value: -74 (4.0%)
| * | | value: -110 (3.0%)
| | * | value: 112 (2.0%)
==== go into positive sinus cycle ===============
bit 0 at 4497 in 33Samples = 1336Hz
Die Information bekommt man allerdings aus dem WAVE modul nicht raus, oder? Zumindest finde ich nichts dazu bei http://docs.python.org/2/library/wave.htmlSirius3 hat geschrieben:Neben 8, 16, 32bit gibt es eben noch signed und unsigned-Datentypen in WAVE-Files.
Stimmt. Allerdings würde ich gern auf audioop verzichten, wenn's geht.BlackJack hat geschrieben:Ich habe mir dann mit der `audioop.bias()`-Funktion beholfen um das zu korrigieren.
Das heißt doch aber auch, das ich einfach pauschal bei 8-bit waves 128 addieren kann.In some audio formats, such as .WAV files, 16 and 32 bit samples are signed, but 8 bit samples are unsigned. So when converting to 8 bit wide samples for these formats, you need to also add 128 to the result:
new_frames = audioop.lin2lin(frames, old_width, 1)
new_frames = audioop.bias(new_frames, 1, 128)
The same, in reverse, has to be applied when converting from 8 to 16 or 32 bit width samples.
Code: Alles auswählen
| | * | value: 64 (3.0%)
| | * | value: 65 (3.0%)
| | * | value: 64 (3.0%)
| | * | value: 65 (3.0%)
| | * | value: 64 (3.0%)
| | * | value: 64 (3.0%)
| | * | value: 65 (3.0%)
| | * | value: 65 (3.0%)
| | * | value: 65 (3.0%)
| * | | value: -128 (2.0%)
| * | | value: -92 (3.0%)
| * | | value: -69 (4.0%)
| * | | value: -76 (4.0%)
| * | | value: -92 (3.0%)
| | * | value: 124 (2.0%)
==== go into positive sinus cycle ===============
| | * | value: 88 (2.0%)
| | * | value: 64 (3.0%)
| | * | value: 65 (3.0%)
| | * | value: 88 (2.0%)
| | * | value: 104 (2.0%)
| * | | value: -120 (3.0%)
| * | | value: -100 (3.0%)
| * | | value: -84 (4.0%)
| * | | value: -77 (4.0%)
| * | | value: -68 (4.0%)
| * | | value: -69 (4.0%)
| * | | value: -76 (4.0%)
| * | | value: -92 (3.0%)
| * | | value: -108 (3.0%)
| * | | value: -121 (3.0%)
| | * | value: 116 (2.0%)
Code: Alles auswählen
| * | | value: -64 (4.0%)
| * | | value: -63 (5.0%)
| * | | value: -64 (4.0%)
| * | | value: -63 (5.0%)
| * | | value: -64 (4.0%)
| * | | value: -64 (4.0%)
| * | | value: -63 (5.0%)
| * | | value: -63 (5.0%)
| * | | value: -63 (5.0%)
*** Have 1 samples skipped, because to lower amplitude.
| | * | value: 36 (7.0%)
==== go into positive sinus cycle ===============
| | * | value: 59 (4.0%)
| | * | value: 52 (4.0%)
| | * | value: 36 (7.0%)
| *| | value: -4 (64.0%)
| * | | value: -40 (7.0%)
| * | | value: -64 (4.0%)
| * | | value: -63 (5.0%)
| * | | value: -40 (7.0%)
| * | | value: -24 (11.0%)
| |* | value: 8 (31.0%)
| | * | value: 28 (9.0%)
==== go into positive sinus cycle ===============
bit 1 at 21 in 11Samples = 2004Hz
First bit is at: 21
enable half sinus scan
| | * | value: 44 (5.0%)
| | * | value: 51 (5.0%)
| | * | value: 60 (4.0%)
| | * | value: 59 (4.0%)
| | * | value: 52 (4.0%)
| | * | value: 36 (7.0%)
| | * | value: 20 (12.0%)
| |* | value: 7 (36.0%)
| * | | value: -12 (22.0%)
Das liefert nicht die erwarteten Werte. Das folgende allerdings schon:BlackJack hat geschrieben:new_value = (old_value + 128) & 0xff
Code: Alles auswählen
value = value % 0xff - 128
Code: Alles auswählen
In [7]: all(v % 256 == v for v in xrange(256))
Out[7]: True
Code: Alles auswählen
end_count = 3
mid_count = 2
previous_values = frame_values[:end_count] # e.g.: 123-----
mid_values = frame_values[end_count:end_count] # e.g.: ---45---
next_values = frame_values[-end_count:] # e.g.: -----678
if previous_values > 0 and next_values <0:
yield mid_time(mid_values)
Das habe ich mir auch überlegt.jerch hat geschrieben:Z.B. mit einem simplen Glättfilter als moving average der letzten 2 oder 3 Werte.
Code: Alles auswählen
usage: PyDC_cli.py [-h] [-v] [--verbosity {0,10,20,30,40,50}]
[--logfile {0,10,20,30,40,50}]
[--hz_variation HZ_VARIATION]
[--min_volume_ratio MIN_VOLUME_RATIO]
[--avg_count AVG_COUNT] [--end_count END_COUNT]
[--mid_count MID_COUNT]
src dst
Python dragon 32 converter
positional arguments:
src Source filename (.wav/.bas)
dst Destination filename (.wav/.bas)
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--verbosity {0,10,20,30,40,50}
verbosity level to stdout (lower == more output!)
(default: 30)
--logfile {0,10,20,30,40,50}
verbosity level to log file (lower == more output!)
(default: 20)
--hz_variation HZ_VARIATION
How much Hz can signal scatter to match 1 or 0 bit ?
(default: 450)
--min_volume_ratio MIN_VOLUME_RATIO
percent volume to ignore sample (default: 5)
--avg_count AVG_COUNT
How many samples should be merged into a average
value? (default: 0)
--end_count END_COUNT
Sample count that must be pos/neg at once (default: 2)
--mid_count MID_COUNT
Sample count that can be around null (default: 1)
Code: Alles auswählen
~$ python PyDC_cli.py FooBar.wav FooBar.bas