How to resolve the algorithm Morse code step by step in the J programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Morse code step by step in the J programming language
Table of Contents
Problem Statement
Morse code is one of the simplest and most versatile methods of telecommunication in existence. It has been in use for more than 175 years — longer than any other electronic encoding system.
Send a string as audible Morse code to an audio device (e.g., the PC speaker).
As the standard Morse code does not contain all possible characters, you may either ignore unknown characters in the file, or indicate them somehow (e.g. with a different pitch).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Morse code step by step in the J programming language
Source code in the j programming language
require'strings media/wav'
morse=:[:; [:(' ',~' .-' {~ 3&#.inv)&.> (_96{.".0 :0-.LF) {~ a.&i.@toupper
79 448 0 1121 0 0 484 214 644 0 151 692 608 455 205 242 161 134 125 122
121 202 229 238 241 715 637 0 203 0 400 475 5 67 70 22 1 43 25 40 4 53
23 49 8 7 26 52 77 16 13 2 14 41 17 68 71 76 214 0 644 0 401
)
onoffdur=: 0.01*100<.@*(1.2%[)*(4 4#:2 5 13){~' .-'i.]
playmorse=: 30&$: :((wavnote&, 63 __"1)@(onoffdur morse))
morse'this is an example'
- .... .. ... .. ... .- -. . -..- .- -- .--. .-.. .
playmorse'this is an example'
1
12 playmorse'as is this'
1
You may also check:How to resolve the algorithm Padovan n-step number sequences step by step in the EasyLang programming language
You may also check:How to resolve the algorithm Snake step by step in the Java programming language
You may also check:How to resolve the algorithm Rosetta Code/Find bare lang tags step by step in the Phix programming language
You may also check:How to resolve the algorithm Draw a clock step by step in the Sidef programming language
You may also check:How to resolve the algorithm Shell one-liner step by step in the Bc programming language