Giter Site home page Giter Site logo

serega404 / morsesharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from p6laris/morsesharp

0.0 0.0 0.0 110 KB

MorseSharp is a simple lightweight .NET library to Encoding/decoding english and kurdish sentences to morse code and vice versa.

License: MIT License

C# 100.00%

morsesharp's Introduction

MorseSharp

Nuget GitHub release (latest SemVer)

MorseSharp is a .NET library to encoding/decoding up to 8 languages including kurdish and generating audio morse.

alt text

Installation

Use nuget package manager to install MorseSharp.

Install-Package MorseSharp

Usage

1. Text

You can decode/encode use MorseSharp just by instantiating TextMorseConverter class and pass 'Language' enum to specify the language.

using MorseSharp;
TextMorseConverter converter = new TextMorseConverter(Language.English);

Encoding

Calling ConvertTextToMorse method and pass the text to encode the morse:

using MorseSharp;
var morse = await converter.ConvertTextToMorse("Hello");

Decoding

Calling asynchronous methods ConvertMorseToText to decode the morse:

โ— Words must be separated by spaces, words by ( / ), Letters by space " ".

using MorseSharp;

var sentence = await converter.ConvertMorseToText(".... ...");

2. Generating audio

  1. To generate audio first you need to instantiate MorseAudioConverter, there are five overloaded constructor To configure audio options such as language and characters speed, word speed ,frequency. this WinForm example demonstrate the purpose:

MorseAudioConverter is just optimized wrapper of jstoddard's CWLibrary Library.

using MorseSharp;

MorseAudioConverter converter = new(Language.English,25,20,600);
//Or for kurdish language
//MorseAudioConverter converter = new(Language.Kurdish,25,20,600);
  1. Bytes for the generated wav audio can be recived by calling MorseAudioConverter's asynchronous ConvertMorseToAudio method:
try
{
   var morse = await converter.ConvertMorseToAudio("Hello Morse");
}
catch(Exception ex)
{
   MessageBox.Show(ex.Message);
}

3.After getting the bytes you can stream the bytes and play the sound, this example use's SoundPlayer object to play the sound:

SoundPlayer player = new();
using(Stream stream = new MemoryStream(morse))
{
   player.Stream = stream;
   player.PlayAsync();
}

Example

This piece of code encode and decode's the morse and then show it to the console:

using MorseSharp;
using MorseSharp.Converter;


TextMorseConverter Converter = new TextMorseConverter(Language.English);


string morse = string.Empty;
string text = string.Empty;

try
{
    morse = await Converter.ConvertTextToMorse("Hello World");
    text = await Converter.ConvertMorseToText(".... ..");
}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}

Console.WriteLine(morse);
Console.WriteLine(text);

License

MIT License

morsesharp's People

Contributors

p6laris avatar p00laris avatar serega404 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.