<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[Linux Lite Forums - Coding]]></title>
		<link>https://www.linuxliteos.com/forums/</link>
		<description><![CDATA[Linux Lite Forums - https://www.linuxliteos.com/forums]]></description>
		<pubDate>Wed, 29 Apr 2026 17:17:20 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[why does npm install encounter with permission denied error on LinuxLite?]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=8084</link>
			<pubDate>Fri, 14 Jan 2022 14:58:39 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=4985">navid_dada</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=8084</guid>
			<description><![CDATA[I am using LinuxLite V5 and I am trying to clone one repository from git using npm V8.3.0 but it throws this exception:<br />
<br />
    fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone7tt2X1': Permission denied<br />
<br />
I try all of these commands but no progress!!!<br />
<br />
    npm i -g <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    npm i <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    sudo npm i -g <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    sudo npm i <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    npm install --prefix=&#36;HOME/.local --global <a href="https://github.com/MorrisJobke/strengthify.git" target="_blank" rel="noopener" class="mycode_url">https://github.com/MorrisJobke/strengthify.git</a><br />
<br />
    sudo npm install --prefix=&#36;HOME/.local --global <a href="https://github.com/MorrisJobke/strengthify.git" target="_blank" rel="noopener" class="mycode_url">https://github.com/MorrisJobke/strengthify.git</a><br />
<br />
I also run all of these commands in sudo su mode but there was not any progress.<br />
<br />
I also checked folder owner and group and permissions. it is the result:<br />
<br />
    drwxrwxrwx 6 root root 4096 jun 13 14:50 .npm<br />
<br />
How can I solve this problem?]]></description>
			<content:encoded><![CDATA[I am using LinuxLite V5 and I am trying to clone one repository from git using npm V8.3.0 but it throws this exception:<br />
<br />
    fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone7tt2X1': Permission denied<br />
<br />
I try all of these commands but no progress!!!<br />
<br />
    npm i -g <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    npm i <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    sudo npm i -g <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    sudo npm i <a href="https://github.com/nextcloud/strengthify" target="_blank" rel="noopener" class="mycode_url">https://github.com/nextcloud/strengthify</a><br />
<br />
    npm install --prefix=&#36;HOME/.local --global <a href="https://github.com/MorrisJobke/strengthify.git" target="_blank" rel="noopener" class="mycode_url">https://github.com/MorrisJobke/strengthify.git</a><br />
<br />
    sudo npm install --prefix=&#36;HOME/.local --global <a href="https://github.com/MorrisJobke/strengthify.git" target="_blank" rel="noopener" class="mycode_url">https://github.com/MorrisJobke/strengthify.git</a><br />
<br />
I also run all of these commands in sudo su mode but there was not any progress.<br />
<br />
I also checked folder owner and group and permissions. it is the result:<br />
<br />
    drwxrwxrwx 6 root root 4096 jun 13 14:50 .npm<br />
<br />
How can I solve this problem?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Setup Valgrind]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=7935</link>
			<pubDate>Fri, 17 Sep 2021 07:03:34 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=4370">Kevin Perez</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=7935</guid>
			<description><![CDATA[Hey there everyone,<br />
<br />
Not sure how much information one needs to help me get Valgrind to be fully setup. If necessary, I will post the version of Linux Lite and Code::Blocks currently installed on my computer. HOpefully, what is included will be sufficient.<br />
<br />
I am currently using Code::Blocks as my compiler. I have created a simple project by the name of DynIntArray. in this project there are two classes:<br />
DynIntArray &amp; DynVoidArray. Each one has a dynamic array. In order to verify that my project is not leaking memory, I am hoping to use Valgrind. I have already installed it, but I now need to edit the bashrc file so it includes "export VALGRIND_LIB = '/usr/lib/valgrind'. Unfortunately, once I have opened the bashrc file to edit it, I am not sure how to save it. Furthermore, the video I was watching seems to be meant for Ubuntu rather than Linux Lite. How may I open, edit, and save the changes I wish to make to the .bashrc file? Hopefully, with some assistance, I can check to ensure the project is not leaking memory. <br />
<br />
Thank you for reading this post, and I very much look forward to reading your responses.]]></description>
			<content:encoded><![CDATA[Hey there everyone,<br />
<br />
Not sure how much information one needs to help me get Valgrind to be fully setup. If necessary, I will post the version of Linux Lite and Code::Blocks currently installed on my computer. HOpefully, what is included will be sufficient.<br />
<br />
I am currently using Code::Blocks as my compiler. I have created a simple project by the name of DynIntArray. in this project there are two classes:<br />
DynIntArray &amp; DynVoidArray. Each one has a dynamic array. In order to verify that my project is not leaking memory, I am hoping to use Valgrind. I have already installed it, but I now need to edit the bashrc file so it includes "export VALGRIND_LIB = '/usr/lib/valgrind'. Unfortunately, once I have opened the bashrc file to edit it, I am not sure how to save it. Furthermore, the video I was watching seems to be meant for Ubuntu rather than Linux Lite. How may I open, edit, and save the changes I wish to make to the .bashrc file? Hopefully, with some assistance, I can check to ensure the project is not leaking memory. <br />
<br />
Thank you for reading this post, and I very much look forward to reading your responses.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[how to install vscode on linux lite]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=7769</link>
			<pubDate>Tue, 11 May 2021 04:58:26 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=4591">Zaid Ouardi</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=7769</guid>
			<description><![CDATA[sudo apt install code <br />
Reading package lists... Done<br />
Building dependency tree       <br />
Reading state information... Done<br />
E: Unable to locate package code<br />
 <br />
I don't know why vs code isn't installing <br />
<br />
Note :I just installed linux lite as my first ever linux distro and i wanted to use it to learnto code and then contribute to open source projects (like: Linux lite and other linux distros + emulators).<br />
ANd i'm completely new to linux even thoughit's my favourite OS and i even watch dozens of linux related youtube videos.<br />
<br />
Plz i'm asking help from the wonderful community of Linux lite and LINUX in general.<br />
]]></description>
			<content:encoded><![CDATA[sudo apt install code <br />
Reading package lists... Done<br />
Building dependency tree       <br />
Reading state information... Done<br />
E: Unable to locate package code<br />
 <br />
I don't know why vs code isn't installing <br />
<br />
Note :I just installed linux lite as my first ever linux distro and i wanted to use it to learnto code and then contribute to open source projects (like: Linux lite and other linux distros + emulators).<br />
ANd i'm completely new to linux even thoughit's my favourite OS and i even watch dozens of linux related youtube videos.<br />
<br />
Plz i'm asking help from the wonderful community of Linux lite and LINUX in general.<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Free Book - Create Graphical User interfaces with Python]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=7706</link>
			<pubDate>Tue, 30 Mar 2021 01:29:16 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=7706</guid>
			<description><![CDATA[Hello,<br />
a total beginner to Python can make apps with this book.<br />
The book is called "Create Graphical User interfaces with Python" , the digital version is free to download from here (no login or account needed) -<br />
<br />
<a href="https://magpi.raspberrypi.org/books" target="_blank" rel="noopener" class="mycode_url">https://magpi.raspberrypi.org/books</a><br />
<br />
It shows step by step tutorials to make things like -<ul class="mycode_list"><li>a Meme Generator App<br />
</li>
<li>a Paint type App.<br />
</li>
<li>several Game apps<br />
</li>
<li>and other apps<br />
</li>
</ul>
It looks like a really good book for making your very first Python apps.<br />
At the end of each tutorial you will have a fully working app you have coded.<br />
It uses guizero, this is a wrapper for tkinter, tkinter is the #1 used gui builder for Python, the book would be a great place to start making apps.<br />
I hope it encourages you to give app making a try in your free time.<br />
]]></description>
			<content:encoded><![CDATA[Hello,<br />
a total beginner to Python can make apps with this book.<br />
The book is called "Create Graphical User interfaces with Python" , the digital version is free to download from here (no login or account needed) -<br />
<br />
<a href="https://magpi.raspberrypi.org/books" target="_blank" rel="noopener" class="mycode_url">https://magpi.raspberrypi.org/books</a><br />
<br />
It shows step by step tutorials to make things like -<ul class="mycode_list"><li>a Meme Generator App<br />
</li>
<li>a Paint type App.<br />
</li>
<li>several Game apps<br />
</li>
<li>and other apps<br />
</li>
</ul>
It looks like a really good book for making your very first Python apps.<br />
At the end of each tutorial you will have a fully working app you have coded.<br />
It uses guizero, this is a wrapper for tkinter, tkinter is the #1 used gui builder for Python, the book would be a great place to start making apps.<br />
I hope it encourages you to give app making a try in your free time.<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[LiLi pad]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=7703</link>
			<pubDate>Mon, 29 Mar 2021 00:05:53 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=7703</guid>
			<description><![CDATA[Showing the window maximized (the default)<br />
<br />
<img src="https://i.ibb.co/nfnG5zp/1.png" loading="lazy"  alt="[Image: 1.png]" class="mycode_img" /><br />
<br />
<br />
Showing what happens when the Open button is used, the up arrow moves up in the tree of your files for navigating them.<br />
<br />
<img src="https://i.ibb.co/Yct7vrc/3.png" loading="lazy"  alt="[Image: 3.png]" class="mycode_img" /><br />
<br />
]]></description>
			<content:encoded><![CDATA[Showing the window maximized (the default)<br />
<br />
<img src="https://i.ibb.co/nfnG5zp/1.png" loading="lazy"  alt="[Image: 1.png]" class="mycode_img" /><br />
<br />
<br />
Showing what happens when the Open button is used, the up arrow moves up in the tree of your files for navigating them.<br />
<br />
<img src="https://i.ibb.co/Yct7vrc/3.png" loading="lazy"  alt="[Image: 3.png]" class="mycode_img" /><br />
<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[An intro to C and GUI Programming FREE pdf]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=6273</link>
			<pubDate>Sun, 30 Jun 2019 05:05:23 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=6273</guid>
			<description><![CDATA[Hello, <br />
<br />
this is a free book as PDF read online or download free, also available to buy in Printed version. <br />
<br />
<a href="https://www.raspberrypi.org/magpi-issues/C_GUI_Programming.pdf" target="_blank" rel="noopener" class="mycode_url">https://www.raspberrypi.org/magpi-issues...amming.pdf</a>]]></description>
			<content:encoded><![CDATA[Hello, <br />
<br />
this is a free book as PDF read online or download free, also available to buy in Printed version. <br />
<br />
<a href="https://www.raspberrypi.org/magpi-issues/C_GUI_Programming.pdf" target="_blank" rel="noopener" class="mycode_url">https://www.raspberrypi.org/magpi-issues...amming.pdf</a>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[int(3) and int('3') is there a difference? (python3.5)]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=5981</link>
			<pubDate>Wed, 06 Feb 2019 09:50:43 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=2797">teage</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=5981</guid>
			<description><![CDATA[So I'm reading a python3 book and working with int(). I follow the directions everything is fine. They have me typing in the shell int('2') and see the result. I noticed if I type int(2) with no apostrophe i get the same result. So my question is this, is there a difference?]]></description>
			<content:encoded><![CDATA[So I'm reading a python3 book and working with int(). I follow the directions everything is fine. They have me typing in the shell int('2') and see the result. I noticed if I type int(2) with no apostrophe i get the same result. So my question is this, is there a difference?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[missing ruby & json file type icons]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=5935</link>
			<pubDate>Fri, 18 Jan 2019 02:24:19 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=968">trinidad</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=5935</guid>
			<description><![CDATA[My Ruby icons are not showing up in file manager. They show up in the mime type editor, but not in Thunar on the desktop like they should. Json doesn't show up right either. The icons are in the set and show in the mime type editor but not on the desktop. What did I miss?<br />
TC<br />
 ]]></description>
			<content:encoded><![CDATA[My Ruby icons are not showing up in file manager. They show up in the mime type editor, but not in Thunar on the desktop like they should. Json doesn't show up right either. The icons are in the set and show in the mime type editor but not on the desktop. What did I miss?<br />
TC<br />
 ]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Python special editions vol 1-12 - full circle]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=5739</link>
			<pubDate>Wed, 31 Oct 2018 07:49:13 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=5739</guid>
			<description><![CDATA[Hello,<br />
<br />
here is the link to the Free download page for (all) volumes 1-12 of the Python Special Editions by Full Circle magazine.<br />
<br />
<a href="https://fullcirclemagazine.org/python-special-editions/" target="_blank" rel="noopener" class="mycode_url">https://fullcirclemagazine.org/python-special-editions/</a><br />
]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
here is the link to the Free download page for (all) volumes 1-12 of the Python Special Editions by Full Circle magazine.<br />
<br />
<a href="https://fullcirclemagazine.org/python-special-editions/" target="_blank" rel="noopener" class="mycode_url">https://fullcirclemagazine.org/python-special-editions/</a><br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Is anyone using LISP on LL?]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=5510</link>
			<pubDate>Fri, 03 Aug 2018 06:08:36 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=1689">Vera</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=5510</guid>
			<description><![CDATA[Is anyone using LISP on LL?]]></description>
			<content:encoded><![CDATA[Is anyone using LISP on LL?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Stuck again, what's wrong?]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=5473</link>
			<pubDate>Fri, 13 Jul 2018 17:50:59 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=1590">colin</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=5473</guid>
			<description><![CDATA[I'm trying to learn Python3 from the book Learn Python 3 the Hard Way and find it hard going especially when the code keeps on displaying an error. Take for instance, exercise 20.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code># ex20: Functions and Files    <br />
 &nbsp;&nbsp;from sys import argv    <br />
 &nbsp;&nbsp;script, input_file = argv    <br />
 &nbsp;&nbsp;def print_all(f):     &nbsp;&nbsp;print(f.read())    <br />
 &nbsp;&nbsp;def rewind(f):     &nbsp;&nbsp;f.seek(0) &nbsp;&nbsp;<br />
def print_a_line(line_count, f):     &nbsp;&nbsp;print(line_count, f.readline())    <br />
 &nbsp;&nbsp;current_file = open(input_file)    <br />
 &nbsp;&nbsp;print("First let's print the whole file:&#92;n")    <br />
 &nbsp;&nbsp;print_all(current_file)    <br />
 &nbsp;&nbsp;print("Now let's rewind, kind of like a tape.")    <br />
 &nbsp;&nbsp;rewind(current_file)    <br />
 &nbsp;&nbsp;print("Let's print three lines:")    <br />
 &nbsp;&nbsp;current_line = 1 &nbsp;&nbsp;print_a_line(current_line, current_file)    <br />
 &nbsp;&nbsp;current_line = current_line + 1 &nbsp;&nbsp;print_a_line(current_line, current_file)    <br />
 &nbsp;&nbsp;current_line = current_line + 1 &nbsp;&nbsp;print_a_line(current_line, current_file)</code></div></div>I keep getting the following error<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>colin@my_new_LinuxLite4.0:~&#36; python3 ~/python_exp/ex20.pyTraceback (most recent call last):    File "/home/colin/python_exp/ex20.py", line 7, in &lt;module&gt;     &nbsp;&nbsp;script, input_file = argvValueError: not enough vales to unpack (expected 2, got 1)colin@my_new_LinuxLite4.0:~&#36;</code></div></div>I've come across this error on a previous exercise but sadly misplaced my notes on how to remedy the error. Can someone help me please.  <br />
]]></description>
			<content:encoded><![CDATA[I'm trying to learn Python3 from the book Learn Python 3 the Hard Way and find it hard going especially when the code keeps on displaying an error. Take for instance, exercise 20.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code># ex20: Functions and Files    <br />
 &nbsp;&nbsp;from sys import argv    <br />
 &nbsp;&nbsp;script, input_file = argv    <br />
 &nbsp;&nbsp;def print_all(f):     &nbsp;&nbsp;print(f.read())    <br />
 &nbsp;&nbsp;def rewind(f):     &nbsp;&nbsp;f.seek(0) &nbsp;&nbsp;<br />
def print_a_line(line_count, f):     &nbsp;&nbsp;print(line_count, f.readline())    <br />
 &nbsp;&nbsp;current_file = open(input_file)    <br />
 &nbsp;&nbsp;print("First let's print the whole file:&#92;n")    <br />
 &nbsp;&nbsp;print_all(current_file)    <br />
 &nbsp;&nbsp;print("Now let's rewind, kind of like a tape.")    <br />
 &nbsp;&nbsp;rewind(current_file)    <br />
 &nbsp;&nbsp;print("Let's print three lines:")    <br />
 &nbsp;&nbsp;current_line = 1 &nbsp;&nbsp;print_a_line(current_line, current_file)    <br />
 &nbsp;&nbsp;current_line = current_line + 1 &nbsp;&nbsp;print_a_line(current_line, current_file)    <br />
 &nbsp;&nbsp;current_line = current_line + 1 &nbsp;&nbsp;print_a_line(current_line, current_file)</code></div></div>I keep getting the following error<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>colin@my_new_LinuxLite4.0:~&#36; python3 ~/python_exp/ex20.pyTraceback (most recent call last):    File "/home/colin/python_exp/ex20.py", line 7, in &lt;module&gt;     &nbsp;&nbsp;script, input_file = argvValueError: not enough vales to unpack (expected 2, got 1)colin@my_new_LinuxLite4.0:~&#36;</code></div></div>I've come across this error on a previous exercise but sadly misplaced my notes on how to remedy the error. Can someone help me please.  <br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[displaying a monthly calendar]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=5464</link>
			<pubDate>Tue, 10 Jul 2018 21:21:01 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=1590">colin</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=5464</guid>
			<description><![CDATA[I came across a Python 3 tutorial for displaying a monthly calendar and it worked a treat from the command-line but for some reason it would not work after i added the Python shebang <div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#!/usr/bin/env python 3.6.</code></div></div>Instead it would produce a load of errors. Have since been informed that i had to change the file name from calendar.py to my_calendar.py and once again it worked a treat.<br />
Still cannot work it out why the program didn't work because 'calendar' is not a reserved word?  ]]></description>
			<content:encoded><![CDATA[I came across a Python 3 tutorial for displaying a monthly calendar and it worked a treat from the command-line but for some reason it would not work after i added the Python shebang <div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#!/usr/bin/env python 3.6.</code></div></div>Instead it would produce a load of errors. Have since been informed that i had to change the file name from calendar.py to my_calendar.py and once again it worked a treat.<br />
Still cannot work it out why the program didn't work because 'calendar' is not a reserved word?  ]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Project - UK Thunderball killa / Open Source donation Builder]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=5260</link>
			<pubDate>Fri, 18 May 2018 22:49:40 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=5260</guid>
			<description><![CDATA[Hello,<br />
<br />
adjusted Lotto killas so it works for the UK Thunderball draw.<br />
<br />
 <img src="https://preview.ibb.co/mfodty/thunder.png" loading="lazy"  alt="[Image: thunder.png]" class="mycode_img" /><br />
<br />
Screenshot of Thunderball number maker running on Linux Lite in terminal and its code in Gedit.<br />
This will pick your 5 number choices from the 39, and then pick your 1 Thunderball number from the 14 numbers.<br />
It will also give you real life choices to make (interactive)<br />
<br />
Here is the code -<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>from random import *<br />
 <br />
thunderchoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]<br />
<br />
thunderball = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]<br />
 <br />
# Picks 5 numbers from the choices <br />
x = sample(thunderchoices, 5)<br />
<br />
# Picks your thunderball<br />
y = sample(thunderball, 1) &nbsp;&nbsp;<br />
<br />
print x <br />
print y<br />
<br />
print ("You have Options - " "&#92;nDonate a percentage of any wins to your favorite project" "&#92;nDonate the stake instead to your favorite project")</code></div></div><br />
Copy/paste in to Leafpad document in Home folder and save as thunder.py<br />
<br />
<br />
Hold down Ctrl and Alt then press t (Ctrl+Alt+t)<br />
Copy/paste or type into terminal -<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>python thunder.py</code></div></div><br />
Hope you enjoy reading this.]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
adjusted Lotto killas so it works for the UK Thunderball draw.<br />
<br />
 <img src="https://preview.ibb.co/mfodty/thunder.png" loading="lazy"  alt="[Image: thunder.png]" class="mycode_img" /><br />
<br />
Screenshot of Thunderball number maker running on Linux Lite in terminal and its code in Gedit.<br />
This will pick your 5 number choices from the 39, and then pick your 1 Thunderball number from the 14 numbers.<br />
It will also give you real life choices to make (interactive)<br />
<br />
Here is the code -<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>from random import *<br />
 <br />
thunderchoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]<br />
<br />
thunderball = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]<br />
 <br />
# Picks 5 numbers from the choices <br />
x = sample(thunderchoices, 5)<br />
<br />
# Picks your thunderball<br />
y = sample(thunderball, 1) &nbsp;&nbsp;<br />
<br />
print x <br />
print y<br />
<br />
print ("You have Options - " "&#92;nDonate a percentage of any wins to your favorite project" "&#92;nDonate the stake instead to your favorite project")</code></div></div><br />
Copy/paste in to Leafpad document in Home folder and save as thunder.py<br />
<br />
<br />
Hold down Ctrl and Alt then press t (Ctrl+Alt+t)<br />
Copy/paste or type into terminal -<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>python thunder.py</code></div></div><br />
Hope you enjoy reading this.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Project - UK & EU Lottery killas / Open Source donation builders]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=5259</link>
			<pubDate>Fri, 18 May 2018 20:38:06 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=71">bitsnpcs</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=5259</guid>
			<description><![CDATA[removed friendliness, it is off topic here Admin says.<br />
<br />
<br />
<br />
<br />
<img src="https://preview.ibb.co/hfQrfd/lot.png" loading="lazy"  alt="[Image: lot.png]" class="mycode_img" /><br />
<br />
UK lottery random number picker, showing the Python code, and the successful running of this in Linux Lite Terminal.<br />
<br />
Here is the code -<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>from random import *<br />
 lottochoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]<br />
<br />
# Picks 6 lotto numbers from the choices <br />
x = sample(lottochoices, 6)<br />
print x <br />
<br />
print ("You have Options - " "&#92;nDonate a percentage of any wins to your favorite project" "&#92;nDonate the stake instead to your favorite project")</code></div></div><br />
Copy/paste this into a leafpad file in your Home Directory and name this file <span style="font-weight: bold;" class="mycode_b">lot.py</span><br />
<br />
To run the file do -<br />
Hold down Ctrl + Alt and press t (Ctrl+Alt+t)<br />
Copy/paste or type in to your terminal <br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>python lot.py</code></div></div><br />
The output will be of the form shown in the above screenshot, that is 6 numbers randomly picked from the 59 as you would do on a lottery ticket in UK.<br />
Then choose your options in real life (interactive)<br />
<br />
<br />
EU Lottery picker  -<br />
<br />
<img src="https://preview.ibb.co/bRo2Ld/eulot.png" loading="lazy"  alt="[Image: eulot.png]" class="mycode_img" /><br />
<br />
EU lottery screenshot, showing Python code and the successful running of this in Linux Lite terminal.<br />
This will pick from the 50 numbers your 5 numbers.<br />
It will also pick from the 12 numbers your 2 lucky star numbers.<br />
It will also output text with lifestyle options (interactivity)<br />
<br />
Here is the code - <div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>from random import *<br />
 <br />
euchoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]<br />
<br />
luckystars = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]<br />
 <br />
# Picks 5 lotto numbers from the choices <br />
x = sample(euchoices, 5)<br />
<br />
# Picks your lucky stars<br />
y = sample(luckystars, 2) &nbsp;&nbsp;<br />
<br />
print x <br />
print y<br />
<br />
print ("You have Options - " "&#92;nDonate a percentage of any wins to your favorite project" "&#92;nDonate the stake instead to your favorite project")</code></div></div><br />
Copy/paste this into a leafpad file in your Home Directory and name this file <span style="font-weight: bold;" class="mycode_b">eulot.py</span><br />
<br />
To run the file do -<br />
Hold down Ctrl + Alt and press t (Ctrl+Alt+t)<br />
Copy/paste or type in to your terminal <br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>python eulot.py</code></div></div><br />
I hope it was interesting to read.]]></description>
			<content:encoded><![CDATA[removed friendliness, it is off topic here Admin says.<br />
<br />
<br />
<br />
<br />
<img src="https://preview.ibb.co/hfQrfd/lot.png" loading="lazy"  alt="[Image: lot.png]" class="mycode_img" /><br />
<br />
UK lottery random number picker, showing the Python code, and the successful running of this in Linux Lite Terminal.<br />
<br />
Here is the code -<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>from random import *<br />
 lottochoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]<br />
<br />
# Picks 6 lotto numbers from the choices <br />
x = sample(lottochoices, 6)<br />
print x <br />
<br />
print ("You have Options - " "&#92;nDonate a percentage of any wins to your favorite project" "&#92;nDonate the stake instead to your favorite project")</code></div></div><br />
Copy/paste this into a leafpad file in your Home Directory and name this file <span style="font-weight: bold;" class="mycode_b">lot.py</span><br />
<br />
To run the file do -<br />
Hold down Ctrl + Alt and press t (Ctrl+Alt+t)<br />
Copy/paste or type in to your terminal <br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>python lot.py</code></div></div><br />
The output will be of the form shown in the above screenshot, that is 6 numbers randomly picked from the 59 as you would do on a lottery ticket in UK.<br />
Then choose your options in real life (interactive)<br />
<br />
<br />
EU Lottery picker  -<br />
<br />
<img src="https://preview.ibb.co/bRo2Ld/eulot.png" loading="lazy"  alt="[Image: eulot.png]" class="mycode_img" /><br />
<br />
EU lottery screenshot, showing Python code and the successful running of this in Linux Lite terminal.<br />
This will pick from the 50 numbers your 5 numbers.<br />
It will also pick from the 12 numbers your 2 lucky star numbers.<br />
It will also output text with lifestyle options (interactivity)<br />
<br />
Here is the code - <div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>from random import *<br />
 <br />
euchoices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]<br />
<br />
luckystars = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]<br />
 <br />
# Picks 5 lotto numbers from the choices <br />
x = sample(euchoices, 5)<br />
<br />
# Picks your lucky stars<br />
y = sample(luckystars, 2) &nbsp;&nbsp;<br />
<br />
print x <br />
print y<br />
<br />
print ("You have Options - " "&#92;nDonate a percentage of any wins to your favorite project" "&#92;nDonate the stake instead to your favorite project")</code></div></div><br />
Copy/paste this into a leafpad file in your Home Directory and name this file <span style="font-weight: bold;" class="mycode_b">eulot.py</span><br />
<br />
To run the file do -<br />
Hold down Ctrl + Alt and press t (Ctrl+Alt+t)<br />
Copy/paste or type in to your terminal <br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>python eulot.py</code></div></div><br />
I hope it was interesting to read.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Using Linux has inspired me to learn C and here's my MORSE program]]></title>
			<link>https://www.linuxliteos.com/forums/showthread.php?tid=5142</link>
			<pubDate>Tue, 03 Apr 2018 01:31:17 +0800</pubDate>
			<dc:creator><![CDATA[<a href="https://www.linuxliteos.com/forums/member.php?action=profile&uid=2135">alowe</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.linuxliteos.com/forums/showthread.php?tid=5142</guid>
			<description><![CDATA[Something about using Linux encourages me to learn C. So I wrote a simple program to output morse code.<br />
<br />
I wanted it to play the morse a bit faster but if I reduce the sample lengths any further they fail to play at all. So this looks like it's as far as it will go. Never intended for it to be practical. Just wanted to try something.<br />
<br />
I'm not sure if attaching Linux executables is safe or advisable (it isn't on Windows systems). Incase it doesn't work or you want to compile it yourself, here is the code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// Compilation:<br />
//  gcc -o morse morse.c -lao -ldl -lm<br />
<br />
#include &lt;stdio.h&gt;<br />
#include &lt;unistd.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;ao/ao.h&gt;<br />
#include &lt;math.h&gt;<br />
<br />
#define bool char<br />
#define true 1<br />
#define false 0<br />
<br />
#define dot 25200&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// length of dot sound<br />
#define dash 44100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// length of dash sound<br />
#define delay 200000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// delay in microseconds between dots and dashes in morse code<br />
<br />
const char* morse[] = {<br />
&nbsp;&nbsp;&nbsp;&nbsp;".-",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// A<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-...", &nbsp;&nbsp;&nbsp;&nbsp;// B<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.-.",&nbsp;&nbsp;&nbsp;&nbsp;// C<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-..",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// D<br />
&nbsp;&nbsp;&nbsp;&nbsp;".",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// E<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..-.",&nbsp;&nbsp;&nbsp;&nbsp;// F<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--.",&nbsp;&nbsp;&nbsp;&nbsp;// G<br />
&nbsp;&nbsp;&nbsp;&nbsp;"....",&nbsp;&nbsp;&nbsp;&nbsp;// H<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// I<br />
&nbsp;&nbsp;&nbsp;&nbsp;".---",&nbsp;&nbsp;&nbsp;&nbsp;// J<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.-",&nbsp;&nbsp;&nbsp;&nbsp;// K<br />
&nbsp;&nbsp;&nbsp;&nbsp;".-..",&nbsp;&nbsp;&nbsp;&nbsp;// L<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// M<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// N<br />
&nbsp;&nbsp;&nbsp;&nbsp;"---",&nbsp;&nbsp;&nbsp;&nbsp;// O<br />
&nbsp;&nbsp;&nbsp;&nbsp;".--.",&nbsp;&nbsp;&nbsp;&nbsp;// P<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--.-",&nbsp;&nbsp;&nbsp;&nbsp;// Q<br />
&nbsp;&nbsp;&nbsp;&nbsp;".-.",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// R<br />
&nbsp;&nbsp;&nbsp;&nbsp;"...",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// S<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// T<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..-",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// U<br />
&nbsp;&nbsp;&nbsp;&nbsp;"...-",&nbsp;&nbsp;&nbsp;&nbsp;// V<br />
&nbsp;&nbsp;&nbsp;&nbsp;".--",&nbsp;&nbsp;&nbsp;&nbsp;// W<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-..-",&nbsp;&nbsp;&nbsp;&nbsp;// X<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.--",&nbsp;&nbsp;&nbsp;&nbsp;// Y<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--..",&nbsp;&nbsp;&nbsp;&nbsp;// Z<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-----",&nbsp;&nbsp;&nbsp;&nbsp;// 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;".----",&nbsp;&nbsp;&nbsp;&nbsp;// 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..---",&nbsp;&nbsp;&nbsp;&nbsp;// 2<br />
&nbsp;&nbsp;&nbsp;&nbsp;"...--",&nbsp;&nbsp;&nbsp;&nbsp;// 3<br />
&nbsp;&nbsp;&nbsp;&nbsp;"....-",&nbsp;&nbsp;&nbsp;&nbsp;// 4<br />
&nbsp;&nbsp;&nbsp;&nbsp;".....",&nbsp;&nbsp;&nbsp;&nbsp;// 5<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-....",&nbsp;&nbsp;&nbsp;&nbsp;// 6<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--...",&nbsp;&nbsp;&nbsp;&nbsp;// 7<br />
&nbsp;&nbsp;&nbsp;&nbsp;"---..",&nbsp;&nbsp;&nbsp;&nbsp;// 8<br />
&nbsp;&nbsp;&nbsp;&nbsp;"----."&nbsp;&nbsp;&nbsp;&nbsp;// 9<br />
};<br />
<br />
void dotdash(char* code, ao_device* device, char* buffer, char audio, char reveal, char suppress)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;// exit early if there's nothing to do<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (!audio &amp;&amp; suppress) return;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// play dot and dash sounds for each dot and dash in code<br />
&nbsp;&nbsp;&nbsp;&nbsp;for (int i=0; i &lt; strlen(code); i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (audio) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (code[i]) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case '.': ao_play(device, buffer, dot); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case '-': ao_play(device, buffer, dash); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ignore other characters<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (reveal &amp;&amp; !suppress) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%c", code[i]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usleep(delay);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (reveal &amp;&amp; !suppress) printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;usleep(delay);<br />
}<br />
<br />
int main(int argc, char** argv)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;ao_device* device;<br />
&nbsp;&nbsp;&nbsp;&nbsp;ao_sample_format format;<br />
&nbsp;&nbsp;&nbsp;&nbsp;char* buffer;<br />
&nbsp;&nbsp;&nbsp;&nbsp;float freq = 1000.0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// the pitch of the sound<br />
&nbsp;&nbsp;&nbsp;&nbsp;int default_driver, buf_size, sample, i;<br />
&nbsp;&nbsp;&nbsp;&nbsp;char ascii, opt, optcount=0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;bool audio=false, reveal=false, suppress=false;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// read options<br />
&nbsp;&nbsp;&nbsp;&nbsp;for (i=1; i&lt;argc; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (argv[i][0] == '-' &amp;&amp; strlen(argv[i]) &gt; 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opt = (argv[i][1] &gt;= 65 &amp;&amp; argv[i][1] &lt;= 90) ? argv[i][1] + 32 : argv[i][1];&nbsp;&nbsp;&nbsp;&nbsp;// convert to lower case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (opt) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'a': audio = true; optcount++; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'r': reveal = true; optcount++; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 's': suppress=true; optcount++; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ignore all unrecognised options<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;// the final argument is assumed to be the text to be translated<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// initialise default audio driver<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (audio) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ao_initialize();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default_driver = ao_default_driver_id();<br />
&nbsp;&nbsp;&nbsp;&nbsp;        memset(&amp;format, 0, sizeof(format));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.bits = 16;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.channels = 2;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.rate = 44100;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.byte_format = AO_FMT_LITTLE;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// open audio driver<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;device = ao_open_live(default_driver, &amp;format, NULL);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (device == NULL) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!suppress) printf("Error opening audio device.&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr, "Error opening audio device.&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// create morse sound<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf_size = format.bits/8 * format.channels * format.rate;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer = calloc(buf_size, sizeof(char));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i = 0; i &lt; format.rate; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sample = (int)(0.75 * 32768.0 * sin(2 * M_PI * freq * ((float) i/format.rate)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// left and right channel<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer[4*i] = buffer[4*i+2] = sample &amp; 0xff;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer[4*i+1] = buffer[4*i+3] = (sample &gt;&gt; 8) &amp; 0xff;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// disable audio and reveal options if audio failed to initialise<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (device == NULL) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;audio = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reveal = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// usage<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (argc == 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Usage: morse [opt] [text]&#92;n&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" -a&nbsp;&nbsp;&nbsp;&nbsp;output audio (requires libao): sudo apt-get install libao-dev&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" -r&nbsp;&nbsp;&nbsp;&nbsp;reveal morse as audio is played&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" -s&nbsp;&nbsp;&nbsp;&nbsp;suppress text output&#92;n&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Translates to international morse code. Put text in quotes if including spaces.&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Only alphanumeric characters translated. All other characters are ignored.&#92;n");<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// output text translation<br />
&nbsp;&nbsp;&nbsp;&nbsp;} else if (argc &gt; optcount + 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// regardless of audio, if there is no reveal just print the morse quickly<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!reveal &amp;&amp; !suppress) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i=0; i &lt; strlen(argv[argc-1]); i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ascii = argv[argc-1][i];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ascii == 32) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// spaces<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if (ascii &gt;= 48 &amp;&amp; ascii &lt;= 57) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// numbers 0 to 9...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%s", morse[ascii-48+26]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if ( (ascii &gt;= 65 &amp;&amp; ascii &lt;= 90) || (ascii &gt;=97 &amp;&amp; ascii &lt;= 122) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// letters a to z...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( ascii &gt;= 97 ) ascii -= 32;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%s", morse[ascii-65]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ascii != 32 ) printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// but if there is audio or the morse is being revealed in morse timing then step though it<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (audio || reveal) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i=0; i &lt; strlen(argv[argc-1]); i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ascii = argv[argc-1][i];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ascii == 32) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// spaces<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!suppress) printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usleep(delay*2);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if (ascii &gt;= 48 &amp;&amp; ascii &lt;= 57) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// numbers 0 to 9...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dotdash((char*) morse[ascii-48+26], device, buffer, audio, reveal, suppress);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if ( (ascii &gt;= 65 &amp;&amp; ascii &lt;= 90) || (ascii &gt;=97 &amp;&amp; ascii &lt;= 122) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// letters a to z...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( ascii &gt;= 97 ) ascii -= 32;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dotdash((char*) morse[ascii-65], device, buffer, audio, reveal, suppress);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!suppress) printf("&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// close and shutdown<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (audio) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ao_close(device);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ao_shutdown();<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;return (device == NULL) ? 0 : 1;<br />
}</code></div></div><br />
I can see things that could be improved but resisting the urge to tinker further. E.g. reveal should still work even if the audio driver fails to load and the final return doesn't need a ternary operator. Must resist urge to tinker...<br />
<br />
Expected output:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Usage: morse [opt] [text]<br />
<br />
 -a&nbsp;&nbsp;&nbsp;&nbsp;output audio (requires libao): sudo apt-get install libao-dev<br />
 -r&nbsp;&nbsp;&nbsp;&nbsp;reveal morse as audio is played<br />
 -s&nbsp;&nbsp;&nbsp;&nbsp;suppress text output<br />
<br />
Translates to international morse code. Put text in quotes if including spaces.<br />
Only alphanumeric characters translated. All other characters are ignored.</code></div></div><br />
Any number of options can be given in any order. If using audio, the morse is played slowly enough that you can learn how to recognise the sounds. If you wanted to use it to play fast morse I guess you could sample the raw output into something like Audacity and then speed it up without raising the pitch. If your device doesn't support direct sampling internally then just use a male to male audio jack between the microphone and headphone inputs. Does the job.<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Edit:</span><br />
Have attached an example.mp3 file to show what that the following message sounds like when sped up in Audacity:<br />
"Example of output from the morse program"]]></description>
			<content:encoded><![CDATA[Something about using Linux encourages me to learn C. So I wrote a simple program to output morse code.<br />
<br />
I wanted it to play the morse a bit faster but if I reduce the sample lengths any further they fail to play at all. So this looks like it's as far as it will go. Never intended for it to be practical. Just wanted to try something.<br />
<br />
I'm not sure if attaching Linux executables is safe or advisable (it isn't on Windows systems). Incase it doesn't work or you want to compile it yourself, here is the code:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// Compilation:<br />
//  gcc -o morse morse.c -lao -ldl -lm<br />
<br />
#include &lt;stdio.h&gt;<br />
#include &lt;unistd.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;ao/ao.h&gt;<br />
#include &lt;math.h&gt;<br />
<br />
#define bool char<br />
#define true 1<br />
#define false 0<br />
<br />
#define dot 25200&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// length of dot sound<br />
#define dash 44100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// length of dash sound<br />
#define delay 200000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// delay in microseconds between dots and dashes in morse code<br />
<br />
const char* morse[] = {<br />
&nbsp;&nbsp;&nbsp;&nbsp;".-",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// A<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-...", &nbsp;&nbsp;&nbsp;&nbsp;// B<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.-.",&nbsp;&nbsp;&nbsp;&nbsp;// C<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-..",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// D<br />
&nbsp;&nbsp;&nbsp;&nbsp;".",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// E<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..-.",&nbsp;&nbsp;&nbsp;&nbsp;// F<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--.",&nbsp;&nbsp;&nbsp;&nbsp;// G<br />
&nbsp;&nbsp;&nbsp;&nbsp;"....",&nbsp;&nbsp;&nbsp;&nbsp;// H<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// I<br />
&nbsp;&nbsp;&nbsp;&nbsp;".---",&nbsp;&nbsp;&nbsp;&nbsp;// J<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.-",&nbsp;&nbsp;&nbsp;&nbsp;// K<br />
&nbsp;&nbsp;&nbsp;&nbsp;".-..",&nbsp;&nbsp;&nbsp;&nbsp;// L<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// M<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// N<br />
&nbsp;&nbsp;&nbsp;&nbsp;"---",&nbsp;&nbsp;&nbsp;&nbsp;// O<br />
&nbsp;&nbsp;&nbsp;&nbsp;".--.",&nbsp;&nbsp;&nbsp;&nbsp;// P<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--.-",&nbsp;&nbsp;&nbsp;&nbsp;// Q<br />
&nbsp;&nbsp;&nbsp;&nbsp;".-.",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// R<br />
&nbsp;&nbsp;&nbsp;&nbsp;"...",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// S<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// T<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..-",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// U<br />
&nbsp;&nbsp;&nbsp;&nbsp;"...-",&nbsp;&nbsp;&nbsp;&nbsp;// V<br />
&nbsp;&nbsp;&nbsp;&nbsp;".--",&nbsp;&nbsp;&nbsp;&nbsp;// W<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-..-",&nbsp;&nbsp;&nbsp;&nbsp;// X<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-.--",&nbsp;&nbsp;&nbsp;&nbsp;// Y<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--..",&nbsp;&nbsp;&nbsp;&nbsp;// Z<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-----",&nbsp;&nbsp;&nbsp;&nbsp;// 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;".----",&nbsp;&nbsp;&nbsp;&nbsp;// 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;"..---",&nbsp;&nbsp;&nbsp;&nbsp;// 2<br />
&nbsp;&nbsp;&nbsp;&nbsp;"...--",&nbsp;&nbsp;&nbsp;&nbsp;// 3<br />
&nbsp;&nbsp;&nbsp;&nbsp;"....-",&nbsp;&nbsp;&nbsp;&nbsp;// 4<br />
&nbsp;&nbsp;&nbsp;&nbsp;".....",&nbsp;&nbsp;&nbsp;&nbsp;// 5<br />
&nbsp;&nbsp;&nbsp;&nbsp;"-....",&nbsp;&nbsp;&nbsp;&nbsp;// 6<br />
&nbsp;&nbsp;&nbsp;&nbsp;"--...",&nbsp;&nbsp;&nbsp;&nbsp;// 7<br />
&nbsp;&nbsp;&nbsp;&nbsp;"---..",&nbsp;&nbsp;&nbsp;&nbsp;// 8<br />
&nbsp;&nbsp;&nbsp;&nbsp;"----."&nbsp;&nbsp;&nbsp;&nbsp;// 9<br />
};<br />
<br />
void dotdash(char* code, ao_device* device, char* buffer, char audio, char reveal, char suppress)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;// exit early if there's nothing to do<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (!audio &amp;&amp; suppress) return;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// play dot and dash sounds for each dot and dash in code<br />
&nbsp;&nbsp;&nbsp;&nbsp;for (int i=0; i &lt; strlen(code); i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (audio) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (code[i]) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case '.': ao_play(device, buffer, dot); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case '-': ao_play(device, buffer, dash); break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ignore other characters<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (reveal &amp;&amp; !suppress) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%c", code[i]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usleep(delay);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (reveal &amp;&amp; !suppress) printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;usleep(delay);<br />
}<br />
<br />
int main(int argc, char** argv)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;ao_device* device;<br />
&nbsp;&nbsp;&nbsp;&nbsp;ao_sample_format format;<br />
&nbsp;&nbsp;&nbsp;&nbsp;char* buffer;<br />
&nbsp;&nbsp;&nbsp;&nbsp;float freq = 1000.0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// the pitch of the sound<br />
&nbsp;&nbsp;&nbsp;&nbsp;int default_driver, buf_size, sample, i;<br />
&nbsp;&nbsp;&nbsp;&nbsp;char ascii, opt, optcount=0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;bool audio=false, reveal=false, suppress=false;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// read options<br />
&nbsp;&nbsp;&nbsp;&nbsp;for (i=1; i&lt;argc; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (argv[i][0] == '-' &amp;&amp; strlen(argv[i]) &gt; 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opt = (argv[i][1] &gt;= 65 &amp;&amp; argv[i][1] &lt;= 90) ? argv[i][1] + 32 : argv[i][1];&nbsp;&nbsp;&nbsp;&nbsp;// convert to lower case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (opt) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'a': audio = true; optcount++; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'r': reveal = true; optcount++; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 's': suppress=true; optcount++; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ignore all unrecognised options<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;// the final argument is assumed to be the text to be translated<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// initialise default audio driver<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (audio) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ao_initialize();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default_driver = ao_default_driver_id();<br />
&nbsp;&nbsp;&nbsp;&nbsp;        memset(&amp;format, 0, sizeof(format));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.bits = 16;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.channels = 2;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.rate = 44100;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.byte_format = AO_FMT_LITTLE;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// open audio driver<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;device = ao_open_live(default_driver, &amp;format, NULL);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (device == NULL) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!suppress) printf("Error opening audio device.&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr, "Error opening audio device.&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// create morse sound<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf_size = format.bits/8 * format.channels * format.rate;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer = calloc(buf_size, sizeof(char));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i = 0; i &lt; format.rate; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sample = (int)(0.75 * 32768.0 * sin(2 * M_PI * freq * ((float) i/format.rate)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// left and right channel<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer[4*i] = buffer[4*i+2] = sample &amp; 0xff;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer[4*i+1] = buffer[4*i+3] = (sample &gt;&gt; 8) &amp; 0xff;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// disable audio and reveal options if audio failed to initialise<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (device == NULL) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;audio = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reveal = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// usage<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (argc == 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Usage: morse [opt] [text]&#92;n&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" -a&nbsp;&nbsp;&nbsp;&nbsp;output audio (requires libao): sudo apt-get install libao-dev&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" -r&nbsp;&nbsp;&nbsp;&nbsp;reveal morse as audio is played&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" -s&nbsp;&nbsp;&nbsp;&nbsp;suppress text output&#92;n&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Translates to international morse code. Put text in quotes if including spaces.&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Only alphanumeric characters translated. All other characters are ignored.&#92;n");<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// output text translation<br />
&nbsp;&nbsp;&nbsp;&nbsp;} else if (argc &gt; optcount + 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// regardless of audio, if there is no reveal just print the morse quickly<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!reveal &amp;&amp; !suppress) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i=0; i &lt; strlen(argv[argc-1]); i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ascii = argv[argc-1][i];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ascii == 32) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// spaces<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if (ascii &gt;= 48 &amp;&amp; ascii &lt;= 57) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// numbers 0 to 9...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%s", morse[ascii-48+26]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if ( (ascii &gt;= 65 &amp;&amp; ascii &lt;= 90) || (ascii &gt;=97 &amp;&amp; ascii &lt;= 122) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// letters a to z...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( ascii &gt;= 97 ) ascii -= 32;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%s", morse[ascii-65]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ascii != 32 ) printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// but if there is audio or the morse is being revealed in morse timing then step though it<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (audio || reveal) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i=0; i &lt; strlen(argv[argc-1]); i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ascii = argv[argc-1][i];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ascii == 32) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// spaces<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!suppress) printf(" ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;usleep(delay*2);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if (ascii &gt;= 48 &amp;&amp; ascii &lt;= 57) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// numbers 0 to 9...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dotdash((char*) morse[ascii-48+26], device, buffer, audio, reveal, suppress);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else if ( (ascii &gt;= 65 &amp;&amp; ascii &lt;= 90) || (ascii &gt;=97 &amp;&amp; ascii &lt;= 122) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// letters a to z...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( ascii &gt;= 97 ) ascii -= 32;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dotdash((char*) morse[ascii-65], device, buffer, audio, reveal, suppress);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!suppress) printf("&#92;n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// close and shutdown<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (audio) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ao_close(device);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ao_shutdown();<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;return (device == NULL) ? 0 : 1;<br />
}</code></div></div><br />
I can see things that could be improved but resisting the urge to tinker further. E.g. reveal should still work even if the audio driver fails to load and the final return doesn't need a ternary operator. Must resist urge to tinker...<br />
<br />
Expected output:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Usage: morse [opt] [text]<br />
<br />
 -a&nbsp;&nbsp;&nbsp;&nbsp;output audio (requires libao): sudo apt-get install libao-dev<br />
 -r&nbsp;&nbsp;&nbsp;&nbsp;reveal morse as audio is played<br />
 -s&nbsp;&nbsp;&nbsp;&nbsp;suppress text output<br />
<br />
Translates to international morse code. Put text in quotes if including spaces.<br />
Only alphanumeric characters translated. All other characters are ignored.</code></div></div><br />
Any number of options can be given in any order. If using audio, the morse is played slowly enough that you can learn how to recognise the sounds. If you wanted to use it to play fast morse I guess you could sample the raw output into something like Audacity and then speed it up without raising the pitch. If your device doesn't support direct sampling internally then just use a male to male audio jack between the microphone and headphone inputs. Does the job.<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Edit:</span><br />
Have attached an example.mp3 file to show what that the following message sounds like when sped up in Audacity:<br />
"Example of output from the morse program"]]></content:encoded>
		</item>
	</channel>
</rss>