Skip to content

Commit

Permalink
Merge to master #26
Browse files Browse the repository at this point in the history
  • Loading branch information
p6laris committed Nov 20, 2023
2 parents 4d5e347 + e701a8e commit 60177e8
Show file tree
Hide file tree
Showing 43 changed files with 1,604 additions and 715 deletions.
22 changes: 10 additions & 12 deletions AudioExample/AudioExample.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\MorseSharp\MorseSharp.csproj" />
</ItemGroup>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MorseSharp\MorseSharp.csproj" />
</ItemGroup>
</Project>
120 changes: 71 additions & 49 deletions AudioExample/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 57 additions & 17 deletions AudioExample/MainWindow.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using MorseSharp;
using MorseSharp.Converter;
using System.IO;
using System.Media;
namespace AudioExample
{
public partial class MainWindow : Form
{
//Declare memory of bytes
Memory<byte> bytes = default;
byte[] bytes = default;

string morse;
//Language
Language language;

//Declare SoundPlayer object to play the sound form the stream
SoundPlayer soundPlayer;
Expand All @@ -20,26 +23,31 @@ public MainWindow()
soundPlayer = new();
}

private async void ToAudioBtn_Click(object sender, EventArgs e)
private void ToAudioBtn_Click(object sender, EventArgs e)
{
//Delcare and init MorseSharp MorseAudioConverter object to convert morse to audio of dash and dots.
MorseAudioConverter converter = new MorseAudioConverter(Language.English);
//Delcare and init MorseSharp MorseTextConverter object to convert sentence to morse dash and dots.
TextMorseConverter textConverter = new TextMorseConverter(Language.English);


try
{
//Check if the message length is greater than zero.
if (MessageMorseTxt.Text.Length > 0)
{
morse = Morse.GetConverter()
.ForLanguage(Language.English)
.ToMorse(MessageMorseTxt.Text).Encode();
//Get wav bytes from the ConvertMorseAudio method and then assigned to memory of bytes
bytes = await converter.ConvertMorseToAudio(MessageMorseTxt.Text);
Morse.GetConverter()
.ForLanguage(Language.English)
.ToAudio(morse)
.SetAudioOptions(25, 25, 600)
.GetBytes(out Span<byte> bytes);

this.bytes = bytes.ToArray();


//Update the richtextbox text to morse dash and dots.
MorseTxt.Text = textConverter.ConvertTextToMorse(MessageMorseTxt.Text);
MorseTxt.Text = morse;

language = Language.English;
//Enable the play button to play
PlayBtn.Enabled = true;
}
Expand All @@ -64,26 +72,36 @@ private void PlayBtn_Click(object sender, EventArgs e)
}
}

private async void ToMorseKurdish_Click(object sender, EventArgs e)
private void ToMorseKurdish_Click(object sender, EventArgs e)
{
//Delcare and init MorseSharp MorseAudioConverter object to convert morse to audio of dash and dots.
MorseAudioConverter converter = new MorseAudioConverter(Language.Kurdish);
////Delcare and init MorseSharp MorseAudioConverter object to convert morse to audio of dash and dots.
//MorseAudioConverter converter = new MorseAudioConverter(Language.Kurdish);

//Delcare and init MorseSharp MorseTextConverter object to convert sentence to morse dash and dots.
TextMorseConverter textConverter = new TextMorseConverter(Language.Kurdish);
////Delcare and init MorseSharp MorseTextConverter object to convert sentence to morse dash and dots.
//TextMorseConverter textConverter = new TextMorseConverter(Language.Kurdish);

try
{
//Check if the message length is greater than zero.
if (MessageMorseTxt.Text.Length > 0)
{
morse = Morse.GetConverter()
.ForLanguage(Language.Kurdish)
.ToMorse(MessageMorseTxt.Text).Encode();
//Get wav bytes from the ConvertMorseAudio method and then assigned to memory of bytes
bytes = await converter.ConvertMorseToAudio(MessageMorseTxt.Text);
Morse.GetConverter()
.ForLanguage(Language.Kurdish)
.ToAudio(morse)
.SetAudioOptions(25, 25, 600)
.GetBytes(out Span<byte> bytes);

this.bytes = bytes.ToArray();


//Update the richtextbox text to morse dash and dots.
MorseTxt.Text = textConverter.ConvertTextToMorse(MessageMorseTxt.Text);
MorseTxt.Text = morse;

language = Language.English;
//Enable the play button to play
PlayBtn.Enabled = true;
}
Expand All @@ -94,5 +112,27 @@ private async void ToMorseKurdish_Click(object sender, EventArgs e)
}

}

private void blinkBtn_Click(object sender, EventArgs e)
{
if (MessageMorseTxt.Text.Length > 0 && morse.Length > 0)
{
Morse.GetConverter()
.ForLanguage(this.language)
.ToLight(morse)
.SetBlinkerOptions(25, 25)
.DoBlinks((hasToBlink) =>
{
if (hasToBlink)
{
blinkerPl.BackColor = Color.Black;
}
else
{
blinkerPl.BackColor = Color.White;
}
});
}
}
}
}
62 changes: 61 additions & 1 deletion AudioExample/MainWindow.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
Expand Down
11 changes: 5 additions & 6 deletions Example/ConsoleExample.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>

<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MorseSharp\MorseSharp.csproj" />
</ItemGroup>

</Project>
</Project>
Loading

0 comments on commit 60177e8

Please sign in to comment.