A world in dk(decay/denmark) » fun http://rotand.dk Just another pointless weblog Sat, 30 Nov 2013 21:03:48 +0000 en-US hourly 1 https://wordpress.org/?v=4.3.18 CLI voip calls http://rotand.dk/2009/05/03/cli-voip-calls/ http://rotand.dk/2009/05/03/cli-voip-calls/#comments Sun, 03 May 2009 08:13:27 +0000 http://rotand.dk/blog/?p=178 front1
Sometimes it would be nice to use a script call somebody and play a message.
I “needed” a wake-up-call system and since I use a voip-phone and have access to a server. I thought i would be quite nifty if I could have the server call me. Furthermore i would like to be able to script calls, so for instance the calendar could call me with reminders rather than sending an email.

I googled around but weren’t able to find such a utility. But i did find cli-sip client pjsua, based on pjsip. Its posible to use it in conjunction with a shell script.

Scripting

jacob@vps:~./control.sh sip:108329@foobar.com "wake up you lazy bastard!"
Is the basic usage i wanted to have. In order to get this functionality there are two steps.

Generating wav file

I ust use text2wave, from festival, which is available as a package on ubuntu.
echo $2 | text2wave - -o message.wav

$2 to use the second argument, and pipe it to text2wave. Let text2wave read sdtin and output a file message.wav

Call and play the wav file

pjsua_app --config-file=test.conf --play-file message.wav $1
Here the magic is in the conf file. Its a rather straightforward to use, and the documentation is good.

# we don't want the host's audio device
--null-audio
# SIP parameters
--realm domain.com
--registrar sip:number@domain.dk # DNS SRV, or FQDN

--username USERNAME
--password PASS
# default of 55 will be rejected as being too short by sipX
--reg-timeout 3600
# auto-answer all calls with "200 OK"
--auto-answer 200
# automatically loop incoming RTP to outgoing RTP
--auto-loop
# mix WAV file into the audio stream

--auto-play
--auto-loop
--duration=60

This is based on a config file i found somewhere, can’t remember where. There a a lot of other options, pjsua handles nat quite nicely as well. It was easy to test it at my homebox, behind a router, just be sure to set an external ip address.

Now this will call and play the message, but it wont stop pjsua. It will just sit around waiting for someone to call. I couldn’t find any nice way to handle this, but since pjsua reads stdin for commands, it possible to pipe commands to it.
echo "sleep 60000 q" | pjsua_app --config-file=test.conf --play-file message.wav $1
So sleep for 60 seconds, then accept the next input from stdin, the “q”uit command.

Generally this configuration is set for 1 minute, it might be necessary to tweak this.

Frustrations

There is/were a bug in the tarball, that meant that it wouldn’t run if it couldn’t find a soundcard, since it should run on a vps this is quite annoying. But in the svn version its solved, so if you want to do something like this, use the svn version. Other than this installation is straightforward.

When working with cron, remember to use full paths. In the control.sh script the better solution were to add a cd working directory, in order to have all the paths correct. This were quite annoying to debug, as the script would run from the shell. And just fail when added to the crontab. Furthermore mails from crontab were delayed, so i couldn’t see the output. I did get someone to look over my shoulder and spot the bug.

]]>
http://rotand.dk/2009/05/03/cli-voip-calls/feed/ 2
Linkdump III http://rotand.dk/2009/03/23/linkdump-iii/ http://rotand.dk/2009/03/23/linkdump-iii/#comments Mon, 23 Mar 2009 06:27:03 +0000 http://rotand.dk/blog/?p=148 Just a couple of links I found. Some I need to remember some are just for fun.

This is why you are fat

Wonderful collection of heart-attack-inducing-gluttony

BikeMap.net

There seems to be a lot of route planners for bicycle routes. So far I have found that this is superior. Easy to work with interface  and a topological chart feature which gives you an easy way to see where the hills is going to be.

Toys from trash

Scientific toys are always cool, they are even cooler when they are made from recycled materials.

Hack Your brain

Fun ways to trick your brain.

The internet is like a penis

via Greg Laden

]]>
http://rotand.dk/2009/03/23/linkdump-iii/feed/ 2
Collection of Processing.org hacks http://rotand.dk/2009/02/27/collection-of-processingorg-hacks/ http://rotand.dk/2009/02/27/collection-of-processingorg-hacks/#comments Fri, 27 Feb 2009 20:07:06 +0000 http://rotand.dk/blog/?p=74 Its been quite a while since I last posted anything.

That doesn’t mean that i haven’t been coding small hacks, just that i haven’t posted them. But now is probably a good time to show some of the stuff.

As the title suggest it has something to do with processing.org. I have been using processing on and off for some time. Its is really nice when you want to make a quick hack, or as its called in processing a “sketch”.

In no particular order here is some of the fun stuff made using processing.

General remarks

The following sketches and their sourcecode have served as small hacks, hence don’t expect nice comments or optimal algorithms…

shrinkImage

It is possible to remove the line from a picture representing the least amount of information. The algorithm evaluates every pixels “weight” as the absolute difference between the different color channels (r,g,b). And then finds the “lightest path” from the bottom to the top.

This means that “prominent features” won’t be removed or change size when shrinking the image. Here the definition of “prominent features” is high difference in colors between the neighboring pixels.

Have a look at shrinkImage

Room for optimizations :

Eventhough its quite quick at calculating the weights and finding the lightest path, it does so in every iteration. Letting it use a bit more memory and just recalculate the changes when removing a line should speed it up. I found a huge speedup when just having an array with the weights from the last and current line, when calculation the path, so not only would saving all weights require a bit more memory it would also slow down the first calculation. But I’m sure it would give a significant speed up in the next iterations, and a lot of +-1 frustrations 😉

helloFoo

There a some quick getting to know processing hacks, this is one off the. helloFoo

One of the very cool things about processing is the ability to use openGL, so originally this sketch uses openGL. But applets and openGL isn’t exactly the best combination. It can be done, but since it doesn’t work for me (firefox, linux openJDK JRE) i just converted it to standard java graphics. And the effort required to do this, is remove an import and don’t say setup(400,400, OPENGL) but just setup(400,400). This is trivially true the other way around. If you want to use openGL its quite easy.

The sketch is just bouncing balls, when going away from openGL I reduced the size and number of balls, in order to get a decent animation speed.

FooIII

Again used openGl originally FooIII

Some satellites rotating around some satellites rotating around some ….

sndHello

yes sketches tend to have silly names : sndHello

From Clifford Pickovers  book : Computers, Pattern, Chaos, and Beauty – graphics from an unseen world (p 39 section 4.3 snowflakes from   sound)
Draw symmetrically and in “polar form” the fft of the sound, hence creating snowflakes based on the sound.
Music by David Rovics
Choppy sound I had some problems with the sound when run as an applet. You might have better luck using the jar directly or by downloading the sourcecode and running it with processing

Slit-scanning

The former applet relied on an external library for the sound, ther are quite a few libraries available. I did use GSvideo to hook up my crappy webcam and do some video effects. I experimented with slit-scanning in different ways.Unfortunately this won’t run as an applet and it might only run on Linux.

By creating a cube of the images, where the z-axis represents time, its possible to play back different parts of the movie from different layers in time. Which makes for some quite interesting and dizzing effects.

For example a time buble where playback is delayed around a “bulge in the timespace continuum” :s (a video of some guy playing with it (timebuble1.avi) some sourcecode for a similar effect where the mouse pointer moves the buble (TimeCube.pde) another more “traditional slitscan” (CamWarpTime.pde) .

In general there is plenty of room to fiddle with the code, there a functions like selectSlice or initQueues where its decided how to slice time. its great fun to play with..

]]>
http://rotand.dk/2009/02/27/collection-of-processingorg-hacks/feed/ 0
New server http://rotand.dk/2008/04/03/new-server/ http://rotand.dk/2008/04/03/new-server/#comments Thu, 03 Apr 2008 19:49:10 +0000 http://rotand.dk/blog/2008/04/03/new-server/ The time has come and I’m moving to a new server.

Its a virtual private server, which mean root access via ssh, and a lot more managing. At the moment I’m fiddling with testing and moving data. Though very soon I will be moving, which probably will give some weirdness here, until everything is settled.

I am looking forward to be able to do all the fun stuff on the new server, ie jsp. In the meantime its just annoying to configure DNS, take backup’s, fixing stuff.

Lessons learned so far :

Its kool to be able to ssh in to the new server and just move everything with ftp and not download and upload.

iconv is a nifty unix command for converting: iconv -f ISO-8859-1 -t UTF-8 file > newFile

DNS is a nightmare at least for me so far.

Its easy to move wordpress: Export everything, install a new wordpress and import the file. (which incidental also means upgrading).

pmwiki is also easy to move.

I have a mediawiki, that I don’t use any more and i couldn’t find an easy way to convert it to static html, so i think ill just have to live without it. Which is a bit annoying since I wikisquatted at it to show of some povray stuff and that will be lost.

I have a lot of old junk files from various experiments.

]]>
http://rotand.dk/2008/04/03/new-server/feed/ 1
DTMF dialer http://rotand.dk/2008/03/20/dtmf-dialer/ http://rotand.dk/2008/03/20/dtmf-dialer/#comments Thu, 20 Mar 2008 20:23:54 +0000 http://rotand.dk/blog/2008/03/20/dtmf-dialer/ UPDATE : see  dtmf-dialer-got-new-features

I got around to hacking some code together for a simple DTMF dialer on the mobile.

Its functional and simple. Enter a number, click ok and it will play the correct sequence of tones. It’s even possible to tweak the duration and pauses.

I have only tested it on my own Nokia 6300, but as far as I can tell it should run on most java enabled mobile phones.

dtmf logo

Here are the jad and jar files. If you want to run the program download them to your mobile and have fun.

At the moment it converts + to 00 and removes +45, as this is appropriate for a danish setting.

Here is the sourcecode if you need to make changes.

DTMF sourcecode

Using Netbeans

I used netbeans 6.0.1 and it was a mixed pleasure. Creating the the flow using a drag’n’drop interface, is well nice for something small and simple as this, but I found that it soon got frustrating. There’s no API to look in, and you have to use the mouse all the time.

dtfmFlow

This is the basic flow of the midlet. It was very quick to set this up, and it were indeed a pleasure to start with. Somewhere along the way a made a mistake, which the flowdesigner and codegenerator couldn’t handle. And no matter what I tried I couldn’t get rid of it, I knew exactly what i was. I had misnamed a variable and managed to let the generated code go into a never-ending recursion. (something along the lines of: private TextField foo() { return new TextField(Foo);} ). But no matter what I tried it just wouldn’t get back to normal. In the end I just created a new project, remade the flow stuff to what you see above, and copied a few functions over.

And the flowdesigner is quick to work with, but I get a nagging suspicion that if you are going to make something a little more complicated than this it will be an annoyance. You might know exactly where and what to change in the source code, but do you remember where to point, click and edit in the designerinterface? Another critique is that even when you know what to do, your workflow gets abruptted by having to constantly shift hands between keyboard and mouse.

To Netbeans defence i must say that I am used to using Eclipse, and changing to another IDE is in it self a frustrating experience. Whats the shortcut for blah, where do I set this. And its quite possible that I just didn’t know enough about Netbeans structure and shortcuts to feel at home.

Credit goes out to : openclipart.org for the image of the phone and dialabc for the soundfiles.

]]>
http://rotand.dk/2008/03/20/dtmf-dialer/feed/ 1
Retro insane asylum telephone http://rotand.dk/2008/03/18/retro-insane-asylum-telephone/ http://rotand.dk/2008/03/18/retro-insane-asylum-telephone/#comments Tue, 18 Mar 2008 20:15:51 +0000 http://rotand.dk/blog/2008/03/18/retro-insane-asylum-telephone/ I recently bought an oldskool rotary phone. I saw it at an auction and it looked nice, but its history was even more fascinating. In its youth it was doing service at the local insane asylum.

insane asylum

image from the museum.

From the leaflet: “Welcome as a patient to the Psychiatric Hospital”
About the Psychiatric Hospital

The highly regarded Copenhagen architect, Gotlieb Bindsboll, built the Jyske Asylum in the middle of the 19th Century. The inspiration for the building, with its crow step gables and many beautiful courtrooms, was taken from the typical Danish manor houses. Its position, with views over the Århus bay was in keeping with the contemporary view of the healing benefits of beauty. The hospital became known as a model institution for the treatment of the mentally ill, also on a European scale. The first part of the hospital was completed in 1852 and it was extended several times over the next fifty years.

kirk phone

The phone is from 1951 1955 and the “electronics” looks aged but in surprisingly good condition. My first plan for it were to gut it, and put a more modern telephone inside, so I could use it for voip. But when I saw that it were in good condition, I thought it would be a shame to kill it entirely.

So I wanted to see whether it would be possible to use it as it is.

For the voip connection i have a PAP2T linksys adaptor (pap), its quite simple to work with. Plug in power and ethernet cable and configure it with a voip service-provider. Initially I used a normal phone to make sure that i had a working setup, before trying to get the rotary phone to work. The normal phone were quite easy to setup and it “just works”.

For the rotary phone there is still some difficulties. But i have managed to get something to work, and I am working on the rest.

First of all i had to change to paps power output to maximum, else it wouldn’t ring the bells. I am still in the process of fiddling with settings for impedance and/or input gain. The problem is that the microphone volume is very low, and if I just turn the input gain up it turns up for the noise as well. It isn’t a problem for me as i have a crisp and clear sound, but apparently it’s a pain to whomever I am talking to. So something has to be done.

Then there is the dialing. A rotary phone dials by using pulse dialing, which in essence means that it disconnects/hangs up, in short intervals as a method of counting the numbers. But any modern voip-adaptor (at least a cheap one) can only function using DTMF. That’s were sending different tones means different numbers. Which basically means that it is enough to send the correct sequence of tones into the microphone in order to dial a number.

I had seen some applets for dialling they did work with the modern telephone, but the rotary phone with its microphone troubles had to get something more. I had success using “DTMF-dial” (from the ubuntu repositories), because it was possible to tweak the duration of tones and pauses.

Next step, as holding the phone to the PC-speaker every time i need to make a phone call, is not an option, were to make a midlet, that’s a mobile applet. A java program for the mobile. Using the mobile as a dialer may seem awkward, but it already holds all my contacts and the voip is a great deal cheaper. I have a midlet at the moment that is at the proof of concept stage. It can dial and I am able to take a number from my address-book dial it using DTMF. It still needs a bit of polishing, but its mostly cosmetic, maybe a list of recent calls would be a nice feature to implement.

soon to come:

  • Nice pictures of the phone, and the electronics.
  • Some software for DTMF dialing on the mobile and a bit about devolping a simple mobile application in netbeans.
]]>
http://rotand.dk/2008/03/18/retro-insane-asylum-telephone/feed/ 2
Flash development http://rotand.dk/2008/02/09/flash-development/ http://rotand.dk/2008/02/09/flash-development/#comments Fri, 08 Feb 2008 21:21:13 +0000 http://rotand.dk/blog/2008/02/09/flash-development/ A course Im taking requires that we use flash and we are left to using specific workstations at school or download a 30 day trial for the 6-7 week project. And well either way we are supposed to be using a proprietary piece of software from Adobe.

The first flash assignment were to create a picture slide show, with captions and a soundtrack. Using the Adobe flash gui its very easy, drag and drop “programming”.

But as Richard Stallman says “its not a matter of convenience, but of ethics”. So I went looking for replacements. In another course I had no problems using octave instead of matlab, so should this be any different? Yes, unfortunately it seems that its very difficult to get the needed features in free software, well at least in the given timeframe.

HaXe is able to compile to swf, as well as doing a lot of other nifty stuff. I just learnt about it recently from this video.

I didn’t manage to make the entire assignment, (yet?) in haxe, but i did make this :
flash presentation(5MB+)

UPDATE

I did manage to add sound and captions.

So how did I do it?

Well first of all i installed haxe and swfmill. Haxe is able to use the actionsscript api and swfmill can create resources so your are able to refference them in you haxe code.Here is the recipe i used to create this slideshow.

1. create a xml file for swfmill, in order to create a resources for the haxe code.This i something like

 <movie width="480" height="480" framerate="25">
   <frame>
      <library><clip id="img1" import="library/newton001Slide_.png"/>

unfortunately swfmill isn’t able to add sound to a library, so that had to be loaded directly from a file. I had some trouble getting it to function on the server but i think that adding “-D network-sandbox” to the haxe compilation might have done something. ???

2. run swfmill, thats swfmill simple slides.xml slides.swf

now i had linkage names for the image files, and could add them to the movieClip.

3. Create file SlideShow.hx

The main part. The basic haxe syntax is pretty straightforward, but since it uses the actionscript api it were mostly a question of getting a hang of actionscript. I did however strugle a bit with making a anonymous function, for the sounds onLoad. I used “static inline function sndStart(succes){…}” , its a wee bit diffrent than what i would do in java. but it works.

3. compile.

make a “make file” for haxe, compile.hxml

-swf test.swf
-main SlideShow
-swf-lib slides.swf
-swf-header 480:480:25:FFFFFF
-D network-sandbox

The last part -D is a conditional flag and as far as i can tell it shouldn’t do anything, but a saw it in Fmp3PlayerHx and when i added it the sound seemed to work from the server, using a URL :s :s

4. run haxe compile.hxml

5. display the pretty result. (try not to go crazy when wordpress decides to help you format the html code….), at first i tried embedding the flash in this post, but wordpress kept on changing the code, apparently if you add code and have newlines between the tags it throws in a couple og <p> tags …..

Now its on a separate page, then you don’t have to download the 5 mb flash file just to view the page, and I can use wordpress with out getting too frustrated.

sourcecode slideShow.hx

The music is “the free software song” this version is by Jono Bacon , and I personally prefer it to the version by Richard Stallman

]]>
http://rotand.dk/2008/02/09/flash-development/feed/ 2
Arduino ps2 mouse http://rotand.dk/2007/11/21/arduino-ps2-mouse/ http://rotand.dk/2007/11/21/arduino-ps2-mouse/#comments Tue, 20 Nov 2007 21:34:16 +0000 http://rotand.dk/blog/2007/11/21/arduino-ps2-mouse/ arduino mouse and anoying encoder
I have been tinkering a bit with the arduino the last couple of days. Mostly small experiments with some of the junk had around, after some frustrations with a circuit for a rotary encoder, i “gave up” and tried hooking up a ps2 mouse. There are a nice tutorial at the arduino playground. It seemed complicated to interface with a mouse this way. But it proved to be so much easier than trying to build a circuit. The software coding is so much easier than the electrical circuits.

It was a matter of connecting 4 wires and uploading the code to get it running. But then i found out that there wasn’t support for the mouse-wheel, so i googled the datasheet for the IC, and started hacking. I ended up getting the mousewheel to function and getting output for the buttons. Along the way I refactored some of code, in order to better understand what was happening.

I still haven’t figured out what I should use the mouse for, but it was a fun hack.

Here is the sourcecode, if you want to try something with it : ps2mouse for arduino

I tried to make nice comments so it should be very straightforward to work with. As mentioned a haven’t made most of the code, just some additions and refactoring.

The mouse and the annoying encoder i couldn’t build a circuit for. It can be attached to a motor where there are a slotted wheel.

(21 nov updated code)

]]> http://rotand.dk/2007/11/21/arduino-ps2-mouse/feed/ 3 TED http://rotand.dk/2007/11/04/ted/ http://rotand.dk/2007/11/04/ted/#comments Sun, 04 Nov 2007 18:20:03 +0000 http://rotand.dk/blog/2007/11/04/ted/ TED is a yearly conference, where people exchange ideas. Hmm that sounds so boring, and yet its not. People at the forefront in different research areas tell about their research and projects.  Well you and I will probably never attend, but the great part is that the talks are online.

They are all about 20 minutes, so its just a quick introduction to the subject.

Vilayanur Ramachandran on your mind 

 A BBC lecture series with Ramachandran peeked my interest in brains, and this talk is a nice summary of some of the more peculiar innerworkings of our brains. Which indeed is more weird than we imagine.

Barry Schwartz on the paradox of choice

 Why more choices doesn’t make us happy. A fun and fascinating talk.

 Dan Dennett on dangerous memes

Dan Dennet is a philosopher and here he talks about religion from a evolutionary perspective. If you are an atheist, this is great stuff as it really gives a good explanation about religion. He also has a great talk about “our consciousness

Dan Gilbert asks, Why are we happy?

 Some interesting facts about happiness and the way it works vs the way we perceive it.

Well this was just a small selection, mostly from the brain/psychology areas. But there are many others in technology, innovation, art, politics etc. From people like Malcom Gladwell, Al Gore, Jeff Han, Richard Dawkins, Nicholas Negroponte, Jane Goodall and a lot of other known and unknown smart people.

But take a look for your self at TED talks

]]>
http://rotand.dk/2007/11/04/ted/feed/ 0
Newton fractals http://rotand.dk/2007/09/22/newton-fractals/ http://rotand.dk/2007/09/22/newton-fractals/#comments Sat, 22 Sep 2007 15:47:35 +0000 http://rotand.dk/blog/2007/09/22/newton-fractals/ I the moment I’m taking a course in Numerical Analysis, and here we were of course introduced to the Newton-Raphson method for finding roots. That is the method where, geometrical speaking, we take at tangent line to a function and use that to approximate the root, and keep on doing that until we reach satisfying precision.

Depending on where you start the iteration you get a a different root, and requiring a different amount of iterations. That’s self-evident. The “funny” part is that when searching for complex roots there are areas in the complex plane, where a very small difference in starting point gives different roots, and with remarkable difference in the number of iterations.

Newton for x^4+2

This is a plot where each root in the polynomial x^4+2 have been assigned a different color. And each point is colored according to which root a iteration starting here finds.

Now thats the mathematical part of it. Now to the beautiful part or at least more fascinating part. The pattern reapeats it self, as a fractal, when you zoom in.

So i modified my code to zoom in, and i used a diffenrent coloring scheme where i only colored according to the number of iterations taken. This made it possible to generate a video zooming in og showing the rapeating patterns in “nice” colors.

Here a some videos :

4 roots (14.6 mb)
7 roots (50 mb)

Yes I know that its very large files, and maybe i will upload them to google video at a later time for easy viewing and less quality.

]]>
http://rotand.dk/2007/09/22/newton-fractals/feed/ 0