diff --git a/Form1.Designer.cs b/Form1.Designer.cs
new file mode 100644
index 0000000..a7f8ce9
--- /dev/null
+++ b/Form1.Designer.cs
@@ -0,0 +1,109 @@
+namespace Magnetic_Card_Reader
+{
+ partial class Form1
+ {
+ ///
+ /// Erforderliche Designervariable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Verwendete Ressourcen bereinigen.
+ ///
+ /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Vom Windows Form-Designer generierter Code
+
+ ///
+ /// Erforderliche Methode für die Designerunterstützung.
+ /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
+ ///
+ private void InitializeComponent()
+ {
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.textBox2 = new System.Windows.Forms.TextBox();
+ this.button1 = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // textBox1
+ //
+ this.textBox1.Location = new System.Drawing.Point(12, 25);
+ this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(437, 20);
+ this.textBox1.TabIndex = 1;
+ this.textBox1.Text = "..\\\\..\\\\..\\\\test-recording.wav";
+ //
+ // textBox2
+ //
+ this.textBox2.Location = new System.Drawing.Point(12, 77);
+ this.textBox2.Name = "textBox2";
+ this.textBox2.ReadOnly = true;
+ this.textBox2.Size = new System.Drawing.Size(554, 20);
+ this.textBox2.TabIndex = 2;
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(455, 23);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(111, 23);
+ this.button1.TabIndex = 3;
+ this.button1.Text = "Read data";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(12, 9);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(156, 13);
+ this.label1.TabIndex = 4;
+ this.label1.Text = "Recorded track 2 wav-file path:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(12, 61);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(68, 13);
+ this.label2.TabIndex = 4;
+ this.label2.Text = "Track2-data:";
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(578, 123);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.textBox2);
+ this.Controls.Add(this.textBox1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.TextBox textBox2;
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+
+ }
+}
+
diff --git a/Form1.cs b/Form1.cs
new file mode 100644
index 0000000..ae769ec
--- /dev/null
+++ b/Form1.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.IO;
+using WaveReader;
+
+namespace Magnetic_Card_Reader
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ int yVal;
+ int lastyVal = 0;
+ int currSide = 1;
+ bool currStateHi = false;
+
+ MagneticCardReader mcReader = new MagneticCardReader();
+ Stream inpFile = new StreamReader(textBox1.Text).BaseStream;
+ WaveData wavData = new WaveData(inpFile);
+
+ for (int i = 0; i < wavData.NumberOfFrames; i++)
+ {
+ yVal = wavData.Samples[0][i];
+ if (yVal > 0x7FFF) yVal -= 0xFFFF;
+
+ //Call addNewSignalState on zero crossing:
+ if (((lastyVal < yVal && currSide < 0) || (lastyVal > yVal && currSide > 0)) && (System.Math.Abs(yVal) > 0xFF))
+ {
+ currSide = 0;
+ currStateHi = (yVal > 0xFF);
+
+ mcReader.addNewSignalState(i, Convert.ToInt32(currStateHi));
+ }
+
+ if (lastyVal * yVal < 1)
+ {
+ currSide = Convert.ToInt32(!currStateHi) * 2 - 1;
+ }
+
+ lastyVal = yVal;
+ }
+
+ textBox2.Text = mcReader.getDataString();
+ inpFile.Close();
+ }
+
+ }
+}
diff --git a/Form1.resx b/Form1.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Magnetic Card Reader.csproj b/Magnetic Card Reader.csproj
new file mode 100644
index 0000000..9929183
--- /dev/null
+++ b/Magnetic Card Reader.csproj
@@ -0,0 +1,89 @@
+
+
+
+ Debug
+ x86
+ 8.0.30703
+ 2.0
+ {F3F1590A-D5C4-4C61-AC0E-B5155F6F1A61}
+ WinExe
+ Properties
+ Magnetic_Card_Reader
+ Magnetic Card Reader
+ v4.0
+ Client
+ 512
+
+
+ x86
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ x86
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
\ No newline at end of file
diff --git a/MagneticCardReader.cs b/MagneticCardReader.cs
new file mode 100644
index 0000000..5dcbfe5
--- /dev/null
+++ b/MagneticCardReader.cs
@@ -0,0 +1,110 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Magnetic_Card_Reader
+{
+ class MagneticCardReader
+ {
+ int lastTimeStamp = 0;
+ double filteredInterval = 0;
+ int dataPointIndex = 0;
+ byte[] decodedData = new byte[1024];
+ int currBitPos = 0;
+ int lastPuls = 0;
+ int startCountDown = 0;
+
+
+
+ private int getParity(byte byteValue)
+ {
+ int A = byteValue;
+
+ A ^= A >> 4;
+ A ^= A >> 2;
+ A ^= A >> 1;
+
+ return A & 1;
+ }
+
+
+ public string getDataString()
+ {
+ /*char[] charTableTrack1 = {' ', '!', '"', '#', '$', '%', '&', '´', '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_'};*/
+
+ char[] charTableTrack2 = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?'};
+
+ char[] charsData = new char[64];
+
+ for (int i = 0; i < 64; i++ )
+ {
+ if (getParity(decodedData[i])==0)
+ {
+ charsData[i] = '_';
+ }
+ else
+ {
+ charsData[i] = charTableTrack2[(decodedData[i] % 16)];
+ }
+ }
+
+ string outPstring = new String(charsData);
+
+ return outPstring;
+ }
+
+ public void addNewSignalState(int timeStamp, int newState)
+ {
+ int shortPuls = 0;
+ int timeInterv = (timeStamp - lastTimeStamp);
+
+ if (dataPointIndex < 18)
+ {
+ if (lastTimeStamp > 0)
+ {
+ filteredInterval = filteredInterval + (double)timeInterv / 16;
+ }
+ }
+ else
+ {
+ if (timeInterv < filteredInterval * 3 / 4)
+ {
+ shortPuls = 1;
+ }
+ else
+ {
+ shortPuls = 0;
+ }
+
+ filteredInterval = filteredInterval * 0.9 + (double)(timeInterv * (shortPuls + 1)) * 0.1;
+
+ if ((lastPuls & shortPuls) == 1)
+ {
+ startCountDown--;
+ if (startCountDown < 0)
+ {
+ decodedData[currBitPos / 5] |= (byte)(1 << (currBitPos % 5));
+ currBitPos++;
+ shortPuls = 0;
+ }
+
+ }
+ else if (shortPuls == 0)
+ {
+ if (startCountDown < 0)
+ {
+ currBitPos++;
+ }
+ }
+ }
+
+ lastPuls = shortPuls;
+ lastTimeStamp = timeStamp;
+ dataPointIndex++;
+ }
+ }
+}
diff --git a/Program.cs b/Program.cs
new file mode 100644
index 0000000..9101b67
--- /dev/null
+++ b/Program.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace Magnetic_Card_Reader
+{
+ static class Program
+ {
+ ///
+ /// Der Haupteinstiegspunkt für die Anwendung.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..0b10e78
--- /dev/null
+++ b/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("Magnetic Card Reader")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("Magnetic Card Reader")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("270fc42c-8d26-4d02-832f-cbcddd701357")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..821cb7b
--- /dev/null
+++ b/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.1
+//
+// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
+// der Code neu generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace Magnetic_Card_Reader.Properties
+{
+
+
+ ///
+ /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
+ ///
+ // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
+ // über ein Tool wie ResGen oder Visual Studio automatisch generiert.
+ // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
+ // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Magnetic_Card_Reader.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
+ /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
new file mode 100644
index 0000000..ffecec8
--- /dev/null
+++ b/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..f564b56
--- /dev/null
+++ b/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.1
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Magnetic_Card_Reader.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
new file mode 100644
index 0000000..abf36c5
--- /dev/null
+++ b/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/WaveReader.cs b/WaveReader.cs
new file mode 100644
index 0000000..c1cd3a0
--- /dev/null
+++ b/WaveReader.cs
@@ -0,0 +1,93 @@
+//A simple C# .NET wave reader library from http://code.google.com/p/dot-net-wave-reader/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+
+namespace WaveReader
+{
+ public class WaveData
+ {
+ private static readonly short BitsPerByte = 8;
+ private static readonly short MaxBits = 16;
+ public short[][] Samples { get; private set; }
+ public short CompressionCode { get; private set; }
+ public short NumberOfChannels { get; private set; }
+ public int SampleRate { get; private set; }
+ public int BytesPerSecond { get; private set; }
+ public short BitsPerSample { get; private set; }
+ public short BlockAlign { get; private set; }
+ public int NumberOfFrames { get; private set; }
+
+ ///
+ /// Reads a Wave file from the input stream, but doesn't close the stream
+ ///
+ /// Input WAVE file stream
+ public WaveData(Stream stream)
+ {
+ using (BinaryReader binaryReader = new BinaryReader(stream))
+ {
+ binaryReader.ReadChars(4); //"RIFF"
+ int length = binaryReader.ReadInt32();
+ binaryReader.ReadChars(4); //"WAVE"
+ string chunkName = new string(binaryReader.ReadChars(4)); //"fmt "
+ int chunkLength = binaryReader.ReadInt32();
+ this.CompressionCode = binaryReader.ReadInt16(); //1 for PCM/uncompressed
+ this.NumberOfChannels = binaryReader.ReadInt16();
+ this.SampleRate = binaryReader.ReadInt32();
+ this.BytesPerSecond = binaryReader.ReadInt32();
+ this.BlockAlign = binaryReader.ReadInt16();
+ this.BitsPerSample = binaryReader.ReadInt16();
+ if ((MaxBits % BitsPerSample) != 0)
+ {
+ throw new Exception("The input stream uses an unhandled SignificantBitsPerSample parameter");
+ }
+ binaryReader.ReadChars(chunkLength - 16);
+ chunkName = new string(binaryReader.ReadChars(4));
+ try
+ {
+ while (chunkName.ToLower() != "data")
+ {
+ binaryReader.ReadChars(binaryReader.ReadInt32());
+ chunkName = new string(binaryReader.ReadChars(4));
+ }
+ }
+ catch
+ {
+ throw new Exception("Input stream misses the data chunk");
+ }
+ chunkLength = binaryReader.ReadInt32();
+ this.NumberOfFrames = (chunkLength * BitsPerByte) / (this.NumberOfChannels * this.BitsPerSample);
+ this.Samples = SplitChannels(binaryReader, this.NumberOfChannels, this.BitsPerSample, this.NumberOfFrames);
+ }
+ }
+
+ public static short[][] SplitChannels(BinaryReader binaryReader, short numberOfChannels, short bitsPerSample, int numberOfFrames)
+ {
+ var samples = new short[numberOfChannels][];
+ for (int channel = 0; channel < numberOfChannels; channel++)
+ {
+ samples[channel] = new short[numberOfFrames];
+ }
+ short readedBits = 0;
+ short numberOfReadedBits = 0;
+ for (int frame = 0; frame < numberOfFrames; frame++)
+ {
+ for (int channel = 0; channel < numberOfChannels; channel++)
+ {
+ while (numberOfReadedBits < bitsPerSample)
+ {
+ readedBits |= (short)(Convert.ToInt16(binaryReader.ReadByte()) << numberOfReadedBits);
+ numberOfReadedBits += BitsPerByte;
+ }
+ var numberOfExcessBits = numberOfReadedBits - bitsPerSample;
+ samples[channel][frame] = (short)(readedBits >> numberOfExcessBits);
+ readedBits %= (short)(1 << numberOfExcessBits);
+ numberOfReadedBits = (short)numberOfExcessBits;
+ }
+ }
+ return samples;
+ }
+ }
+}
diff --git a/bin/Magnetic Card Reader.exe b/bin/Magnetic Card Reader.exe
new file mode 100644
index 0000000..9d15127
Binary files /dev/null and b/bin/Magnetic Card Reader.exe differ
diff --git a/bin/test-recording.wav b/bin/test-recording.wav
new file mode 100644
index 0000000..89836f4
Binary files /dev/null and b/bin/test-recording.wav differ