Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jblond/morse
PHP morse code and wav(e) sound file generation
https://github.com/jblond/morse
audio morse morse-code php skats wav wave
Last synced: 28 days ago
JSON representation
PHP morse code and wav(e) sound file generation
- Host: GitHub
- URL: https://github.com/jblond/morse
- Owner: JBlond
- License: mit
- Created: 2023-08-07T12:36:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-29T07:18:48.000Z (over 1 year ago)
- Last Synced: 2024-11-21T09:09:55.685Z (about 1 month ago)
- Topics: audio, morse, morse-code, php, skats, wav, wave
- Language: PHP
- Homepage:
- Size: 50.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP morse code and wav(e) sound file generation
Supported character sets
- Arabic, Cyrillic, Greek (needs conversion to upper case letters (function included)), Hebrew, Japanese
Korean, Latin, Persian, and Thai.`composer require jblond/morse`
Example UI:
## Examples
```php
stringToMorse('SOS');
$morse = $morse->dotDash($morseBinary);
echo $morse;
$wave = new Wave();
file_put_contents('sos.wav', $wave->generate('SOS'));
```Non latin example
```PHP
setLetters('Cyrillic');
$morse->stringToMorse('Запомнить');
```## Morse API
- `setLetters` Change the origin character set (letters / language)
- available: Arabic, Cyrillic, Greek, Hebrew, Japanese, Korean ([SKATS](https://en.wikipedia.org/wiki/SKATS)), Latin (default), Persian, and Thai.
- `getLetters` Get an array of the current selected character set
- `getCharacter` Convert a single character into morse binary code. An invalid character will return a `#`.
- `stringToMorse` Convert a string into binary morse code.
- `dotDash` Convert binary morse code into dot and dash / dit and dah.### Greek characters
Since the PHP `strtoupper` function fails for Greek, an extra function to do so has been added.
```PHP
setLetters('Greek');
$morse->stringToMorse((new Greek())->stringToUpper('Τέλος εκπομπής'));
```## Wav(e) API
- `setCwSpeed` set words per minute (cw speed). Default is 25.
- `setSampleRate` default is 11050. An audio CD would be 44100 aka 44.1 kHz (16 bit).
- `setFrequency` set the tone height. Default is 700 (cw tone).
- `generate` get the audio as binary.License: MIT