Schmitt trigger... Possible?

Effects, Recipes, Interfacing with other software, etc.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Flavioweb
Posts: 22
Joined: Fri Nov 04, 2016 8:23 pm
Operating System: Linux Debian

Re: Schmitt trigger... Possible?

Post by Flavioweb » Fri Nov 04, 2016 10:26 pm

Ok, thanks a lot guys!
Nyquist code by Steve works as well...
Just one thing: it seems to produce a trail... that i don't want...
Is my mistake?
Attachments
Waves-08.jpg
Waves-08.jpg (51.19 KiB) Viewed 967 times

steve
Site Admin
Posts: 80679
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Schmitt trigger... Possible?

Post by steve » Sat Nov 05, 2016 2:17 am

Flavioweb wrote:Just one thing: it seems to produce a trail... that i don't want...
Is my mistake?
Ensure that you select only the audio that you wish to process. If the selection extends into "white space" beyond the end of the audio, then Nyquist will attempt to process that selected white space as if it is audio.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

flynwill
Posts: 840
Joined: Fri Jan 17, 2014 2:58 pm
Operating System: Linux Debian

Re: Schmitt trigger... Possible?

Post by flynwill » Sun Nov 06, 2016 12:12 am

Do you know what modulation scheme was used to encode the data on these tapes? It sound like you may be attempting to emulate the original decoding hardware, but with the power of a modern computer at your disposal there may be far better methods available.

Also if you find programming in Nyqiest to be painful (and I certainly do), there are pretty extensive python signal processing libraries available.

Flavioweb
Posts: 22
Joined: Fri Nov 04, 2016 8:23 pm
Operating System: Linux Debian

Re: Schmitt trigger... Possible?

Post by Flavioweb » Sun Nov 06, 2016 11:59 am

Modulation scheme may vary from tape to tape and, sometimes, from program to program.
My pourpose is to read signals from these tapes, rebuilding the "square wave data" and convert it to a "digital version" of the tape.
I'still having troubles with Steve's cose, because seems like it modify the lenght of the waves i'm using...
But, since i'm totally new to Nyquist... i'm still trying to understand where are my mistakes...

cyrano
Posts: 2629
Joined: Fri Apr 17, 2015 11:54 pm
Operating System: macOS 10.13 High Sierra

Re: Schmitt trigger... Possible?

Post by cyrano » Sun Nov 06, 2016 2:24 pm

Do you know what computer/software created the tapes?

For some encoding schemes, eg the Commodore 64, DIY hardware solutions exist. That would make the tape transfer much simpler and more reliable. And it's all just 74XX logic, so it doesn't cost an arm and a leg.

Tape stretches and together with noise, it might make the data unreadable.

I don't have a link to the hardware immediately, but if you're the DIY kind and can handle a soldering iron, I could see if I can find it again, if it is still present on the web. IIRC it was a German site, but I seem to remember some sources in the UK too.

Flavioweb
Posts: 22
Joined: Fri Nov 04, 2016 8:23 pm
Operating System: Linux Debian

Re: Schmitt trigger... Possible?

Post by Flavioweb » Sun Nov 06, 2016 2:50 pm

Thanks a lot Cyrano, i know there are hw dedicated solutions to dump tapes.
But i have some signals recorded via not dedicated HW that i want to preserve.

By now i understood that:

Code: Select all

(setf ar (snd-fetch-array *track* 882000 44100))

(setf output 0)
(dotimes (i 882000 (snd-from-array 0 44100 ar))
  (let ((input (aref ar i)))
    (cond
      ((> input 0.2) (setf output 0.8))
      ((< input -0.2) (setf output -0.8)))
    (setf (aref ar i) output)))
works 20 seconds of audio (at 44100 freq).
How can i elaborate full track/selection and not a fixed amount of samples?

steve
Site Admin
Posts: 80679
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Schmitt trigger... Possible?

Post by steve » Sun Nov 06, 2016 6:12 pm

If you could post a short sample of the type of audio that you want to convert, then that will give me a better idea for an appropriate solution.
Please post 5 or 6 seconds in WAV format. (see here for how to post an audio sample: http://forum.audacityteam.org/viewtopic ... 49&t=72887)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Flavioweb
Posts: 22
Joined: Fri Nov 04, 2016 8:23 pm
Operating System: Linux Debian

Re: Schmitt trigger... Possible?

Post by Flavioweb » Sun Nov 06, 2016 7:14 pm

Here it is...
Attachments
tmp_15051--1558906781.wav
(875.44 KiB) Downloaded 40 times

flynwill
Posts: 840
Joined: Fri Jan 17, 2014 2:58 pm
Operating System: Linux Debian

Re: Schmitt trigger... Possible?

Post by flynwill » Mon Nov 07, 2016 4:33 am

Ok, so that bit is pretty clearly FSK. Bits are either ~1800 Hz or ~3600 Hz.

You might want to apply a bit of equalization before attempting to decode them, the 3600 Hz part is about 10 dB down from the 1800Hz bit. Aside from that the signal looks pretty clean to me, a simple threshold should suffice to digitize it, and decoding into a bit stream shouldn't be too hard either (but I would probably not try to do that programming bit in Nyquist.

steve
Site Admin
Posts: 80679
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Schmitt trigger... Possible?

Post by steve » Mon Nov 07, 2016 10:51 am

As flynwill wrote, that appears to be FSK (https://en.wikipedia.org/wiki/Frequency-shift_keying) so turning those waveforms into square waves is the wrong approach. The two digital (binary) states (on/off or 1/0) are not represented by amplitude but by frequency. To "convert to digital" you need to detect the frequencies, then select one binary state (1 or zero) when one frequency is present and the other binary state for the other frequency.

As the signal is always either the higher frequency or the lower frequency, we only need to detect the higher (or lower) frequency, as the other binary state is "everything else".

This code seems to work pretty well on the sample that you posted:

Code: Select all

(setf threshold 0.08)  ;tweak this value as necessary

(let* ((sig (lowpass2 (snd-abs (highpass8 s 3000)) 3000))
       (sig (s-max (diff sig threshold) 0)))
  (clip (mult sig ny:all) 0.8))

Here's a close-up of part of the waveform.
The first track shows the input (the file that you posted).
In the second track, the filtering in the code causes a delay, so the processed output is all a little to the right relative to the original.
The third track is a duplicate of the second track, but I've shifted it a little to the left (using the Time Shift tool) so that you can see how the "digital" output relates to the FSK input.
tracks004.png
tracks004.png (30.1 KiB) Viewed 945 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply