Monday, July 3, 2023

SOX convert Atari audio files for MPC

 this sox command line does the work on audio sampled on an Atari STe with a Mastersound cartridge:

> sox JOAN100.AVR -r 44100 -b 16 joan100A.wav silence 1 0.1 0.1% reverse silence 1 0.1 0.1% reverse

sox reads the .avr header, then upscales to 44.1 khz / 16 bits: we also trim silence from start and end.


here it is embedded as an Automator app for OSX Mojave. I'm sure this will be broken in later OS'


for AVRs that come in smaller than 1kb or so, I think that the trimming associated with remove silence trick used here results in an empty file. I'll get to that

Monday, January 3, 2022

MPCMaid and Java versions on Mac - OSX 10.14

 a requirement to run MPCMaid - http://mpcmaid.sourceforge.net/ - on a Mojave Mac.

Originally written for JRE 1.6 and packaged as a .jar file, it still fires up OK but is missing some important items, the prefs menu items to be specific where you can select the type of MPC you want to create programs for. In my case, an MPC500 that I'm using to test some MIDI processing scripts. 

The following process gets you the app in it's old-school fully-functional state:

1. get an old JRE, Java 6 from Apple: https://support.apple.com/kb/dl1572 and install

2. check your available Java versions:

/usr/libexec/java_home -V

you should see output like the following: 

Matching Java Virtual Machines (5):    

    15.0.1, x86_64: "Java SE 15.0.1" /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home   
    1.8.0_312,       6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-468, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home


3. I chose a 'most compatible' version: ie. the final one and set it as the default:

export JAVA_HOME=`/usr/libexec/java_home -v 1.6.0_65-b14-468, i386`

4. Test running the  .jar now with:

cd /Applications

java -jar mpcmaid_beta.jar

 - all the old menus are restored and it can open/save/export normally

5. make the choice of default JRE permanent by adding the command in 3. above to your .bash_profile.

Thursday, November 9, 2017

verify JSON files in the shell (npm, bash)

I do most of my mass text-processing in Perl. It's been a wake-up that Perl's JSON libraries & tools are a little eccentric (perhaps that shouldn't be surprising) or 'minimal', rather than warm & fuzzy: that would be the best word.

Anyway. Let's verify a bunch of json files in the shell. This follows a lengthy period of combining &  de-duplicating two (pretty crap & overlapping) datasets into a single json format. 

Install jsonlint from via npm: https://www.npmjs.com/package/jsonlint

This gives you a decent executable json linter which may or may not be the same codebase as the ever-awesome http://jsonlint.com/

and call it from the shell:

for f in *.json 
do 
 echo "Processing $f" 
 jsonlint -cq $f 
done

the q flag prevents json printing to the shell & only shows errors

Sunday, October 13, 2013

console colours on RedHat linux

or, how to turn them off. You need sudo or root:

chmod 000 /etc/profile.d/colorls.*

That's a global disable but honestly, dark blue text on black? It's been bugging me for years. RedHat-derived Linux has been shipping with the ls command aliased to /bin/ls --color=auto for an extremely long time though I don't remember anyone asking me about it.

Alternatively, if you want to customise this kind of thing, this article might be a good starting point.


Saturday, October 12, 2013

Web Design: Responsive Image Sizes

Put this in your CSS:

img {
     max-width: 100%;
     height: auto;
}

- making sure it doesn't get overridden at some point in your more specific CSS classes.

This is a prime technique for sites that have some big feature image, usually on the front page that needs to be there when someone looks at it using a smart phone etc. The image will scale on nearly everything except IE8 - for which webdesignerwall offers a specific solution.

Friday, October 4, 2013

a development process for Max MSP or Max for Live

back on the Max jag again - I am building & re-building a small set of patchers to help me create music/soundtracks for some performance works I've been asked to help out with.

One of these - basically a sample-player which uses soundfile markers to determine playback - has been around since 2006 in various forms. I even wrote a helper app for it using Libsndfile, before Patrick Delges' sfmarkers-v0-4-1 object was around (or before I became aware of it's existence).

I think I just rewrote it for the seventh time - it's definately acting in a more consistent manner now. AIFF only - there just seem to be endless uncommon & weird problems getting markers out of WAV files. I also created an M4L version, which was instructive in the problems that embedding in an Ableton project solves (memorising specific setting per-instance of the patch) - and also the extra problems it brings up (access to presets & automation).

The need to move this patch/instrument between a few different Macs sent me off to finally look at version control for Max.

more on this in a minute...

Tuesday, August 20, 2013

Arduino: Motion sensor, making it work

I had some problems getting this PIR motion sensor, which I'm pretty sure is the same as this working well, connected to either an Arduino Duemillanove or a Teensy 2.0 micro. It seemed to trigger randomly or not at all. Based on a clue from the Sparkfun comments on the item: provide the sensor with it's own or extra power as the micro board might not be providing enough volts to drive it properly.

This approach seems to provide the answer: power the PIR sensor with the positive side of a 9v battery, (disconnecting it from the micro board's power), whilst leaving the rest of the circuit (like this) in place.

In hindsight, I'm assuming the problem I had stemmed from the Arduino itself using up all the juice available from the USB connection to the computer. Powering the board from a DC adapter with current to spare would help too.

With a movement/presence detector like this, adding a big LED or a buzzer to your circuit and sketch, indicating when the sensor detects movement will help a lot when testing.


dual-powered: the PIR sensor connected to a Teensy. 9V battery for the sensor, an old phone charger provides +5v via the Teensy's mini USB connector.

Saturday, August 17, 2013

Arduino: Configuring on Linux

You want to install the Arduino development environment on a linux machine: there is the standard download and there are distro-specific installers available. There are also some instruction on setting up your environment linked from the official pages.

The route I followed on my usual distro (Centos 6) was to install Java, then the Arduino download. There were still a couple of non-functioning parts: errors from the rxtx library about lockfiles and greyed out serial port menu in the Arduino IDE.

These are RedHat/Fedora/Centos permissions issues that can be resolved easily:

* edit /etc/group

* add your username to the uucp, lock and dialout groups

That should fix it by giving your user the required access to the computer's lock directory and serial ports 

Wednesday, June 26, 2013

RFID tag collision

What happens if you try to identify 'something' by pinpointing it with an RFID tag - but in too-close proximity to another tag? By the look of things - unpredictability:

http://www.technovelgy.com/ct/Technology-Article.asp?ArtNum=57


Monday, April 8, 2013

monitor websites with websec & cron

Websecretary is not a new piece of software but is still the best free off-the-shelf page monitoring solution that I've been able to find.

It's really as simple as this:
  • un tar the archive, 
  • alter the config file (url.list) - add your mail addresses and the URLs would want to watch
  • run the script (./websec) - it will grab initial copies of your pages
  • run it again later & it will indicate any changes that have occurred
This instant gratification is seductive - running from cron is a little more complicated & this is obviously software which you will want to run on a scheduled basis most of the time - monitoring pages & alerting you to any changes automatically. Aside from the fact that 'cron doesn't run as you' (which I always seem to have forgotten about when I need to setup a new job)  there's a couple of things you need to do for websec in particular:

Let's set it up 
As in the man page - websec's data dir is actually ~/.websec/ - something not immediately obvious after the ease of running interactively like above. The essential components:
  • url.list - the config file
  • ignore.list - configurable stuff to ignore & not count as a change
  • archive - containing copied of the watched pages which are fetched & stored so they can be diff'ed
- need to live in in the above data directory (even if you don't have any ignore data - it needs to be there). So a recipe for for the setup is:

  • configure your websec
  • run it once so it can store initial state (in the archive directory)
  • copy all the files/dirs noted above into  ~/.websec/
  • make sure that the directory which contains the scripts (websec & webdiff) is in your PATH
reate your scheduled job. In cron, something like:

59 * * * * /full/path/to/websec > /dev/null 2>&1

or, if you want the full output for testing etc:

09 * * * * /full/path/to/websec 2>&1 | mail -s "websec run" your@email.dot.dot

Although you still need to full path to the command in there, it's smart enough to find webdiff (if in the same directory) & also to find the data dir (in this sense, cron IS 'running as you' :) )

Wednesday, January 9, 2013

osx86 hibernate problems

Specifically addressing an issue that occasionally arises on my eeePC running OSX 10.6 Snowleopard: it tries to start from a hibernate image (i.e. the screen shows a greyed-out image of the Mac desktop with a segmented progress bar along the bottom) - which never completes restoring & freezes at some point near the end.

The quick solution: boot in safe mode (just like a real Mac - hold the shift key until the silver screen with your disks in the center appears). You can type commands at this point which are arguments to the Chamelon boot loader: in this case try:

WakeImage=(name of a non-existant file) - then hit return

You should now have booted normally...

Longer-term solution: conce you can startup and login normally, the following commands in a terminal:

sudo pmset -a hibernatemode 0
sudo rm /var/vm/sleepimage

i.e turn hibernation off (should still sleep OK on lib close etc) and also free disk space by deleting the hibernation image file (roughly the size of your RAM).




Tuesday, November 6, 2012

free QR code generator

this is the one I've been using: kaywa.com. It just does what it says for me so far: encoding URLS with fairly simple query strings - that scan fine off the computer screen. Google will tell you about x. million other free ones, some of which want you to sign up prior to getting access which is a bit annoying.

Monday, November 5, 2012

a working Perl on xampp

Returning to both Windows and Perl after something of an absence.

The XAMPP application stack is a quick way to get a web server, database and scripting languages onto a Windows box (& other platforms as well). I seem to remember that it was one of the very first one-click application server installers back in the mid-2000s.

Anyway, the version of Perl bundled in the current release (1.8.1) is broken from the point of view of  adding new modules. There's a complex Google trail to be followed but the upshot is: it awaits fixing. It's perfectly usable as a script interpreter but when you try to add modules from CPAN it's missing required system libraries and tools.

The simplest solution is to install Strawberry Perl, which is a port of the language and it's supporting ecosystem to win32 or 64:

* install xampp
* install strawberry perl
* check your environment variables to ensure that strawberry's perl.exe is in the system path (by default: C:\strawberry\perl\bin - rather than inside C:\xampp somewhere).
* alter the shebang line of any cgi scripts you want to call on xampp's apache server to point at strawberry perl (by default at: C:\strawberry\perl\bin\perl.exe).

So your cgi scripts will still live in the location defined in xampp/apache (default: C:\xampp\cgi-bin)  but they will call the strawberry interpreter instead of the bundled one.

This way, your can use the standard CPAN method of adding Perl modules from the command line (perl -MCPAN -e shell) and it will compile and install them into a location where they can be found by strawberry Perl (C:\strawberry\perl\site\lib) - i.e. it's INC path.

Sunday, July 15, 2012

ideas for a Wordpress theme

some ideas to start on a sort of template Wordpress theme. That incorporates the following presentation elements:
  • minimum-height page/content area, which feeds into the next item:
  • sticky-footer - ie. that really, properly, sticks to the bottom of the browser window
  • a single depth-index for positioning elements in front/behind each other, using a common CSS position/z-index mechanism.
  • completely relative or screen-scaling placement of elements (I've recently been reminded how the last-mention 'depth' aspect can interact with simple things like the scrollability of elements).
  • this list should grow...
- probably based upon Thematic or something kind of rational like that. Making the relationships that allow the above kind of interactions explicit and obvious: in that case building a theme is probably the way to get the most general value out of the exercise - it's effectively a level above just doing it as an HTML/CSS/some-script combo because it has to conform to the higher-level organisation of a WP theme for a start.

Then if you begin to add some of the very bread and butter functionality that I think is missing from WP - all logic - ie. theme functions... widgets perhaps...

The last few jobs have involved some deeply defective sites that couldn't be rebuilt for various reasons. Items like the above were really just scratching the surface of nasty dependencies and instant breakages possible with fairly poor HTML/CSS when buried in a Wordpress theme. Somethimes you simply can't do the kind of refactoring or even the rebuild-from-scratch. The last item should always be the last resort but code-analysis/refactoring skills seem to be thin on the ground...

Tuesday, August 30, 2011

samba: running swat from xinetd

(swat - the web-based tool for managing samba servers and accounts)...well, on some (possibly most these days) linux distros it's run out of xinetd, which makes it pretty manageable: After you install your 'samba-swat' package, edit /etc/xinetd.d/swat to enable & configure it.

the critical lines being:
only_from = IP addresses/ranges you want access from
disable = no # the default being 'yes'

Now, less commonly-know it seems is the xinetd directive (ie. would work for all the apps you can wrap with it):

server_args = as-read-from-the-man-page

The server_args in this case being '-P' which limits swat to really only showing the password-change page by hiding the server config and monitoring elements. I don't want normal users to be able to see any of those items.

Thursday, August 4, 2011

atypical web applications

on reflection, there's probably no such thing as a 'typical web app' - they all bring their challenges. I often seem to get the slightly off-centre ones. Not that I'm complaining really but people get told either that something is 'impossible' or is going to cost them 8 grand (which is another way of telling the client to go away).

It often seems that there's a lot of software waiting to be written in the small-business, web/print design space - apps that will encapsulate someones workflow in building or maintaining a complex website, converting images en mass or pulling data into some useful order or interface. Some of these would just be scripts & some real, hosted web applications.

How do you bring these opportunities together? the prospective client and their requirements (and some cash too I hope) and someone who can do the work - to the point where it's complete and actually does what the client wants? It's pretty hard, as I've been finding out. I'm wearing out the opportunities I can see in my network of contacts right now...

***
Actually, I really just want to write about data persistence in the context of work I've performed for clients recently - and crucially - the tech (ie. programming languages, web hosting) I've had little choice but to employ... because this aspect has been really central to even small projects.

I keep coming back to the same thought: Java Servlets(& JSP, JSF kinds of teck built on top of the spec) was the only half-way elegant, well thought out web app framework - and they were more or less complete by 2000. Given the rise of scripting in the intervening decade & the decline of Java outside of enterprise systems we are are actually worse off now than then...

Tuesday, February 1, 2011

Simple Rails app

All you want to do is to get up & running

on OSX Snowleopard (Ruby 1.8.7 - included with the OS & Gem 1.4.2 - after runnning gem update --system) , the sequence of steps to get a simple Rails application up & running:

> rails new app_path/app_name

cd into the  app directory & add anything special  to the Gemfile - which specifies Ruby gems to add to the apps library

> bundle install

>rails server

you should see the WEBrick test server start up

This post is necessary as using this built-in server seems to be really out of favour in Ruby-land (the Mongrel webserver is suggested) & what docs there are about it - well some paths & commands have changed...

gnu screen keyboard commands

tipsheet

I don't know what I did before I discovered Screen but I sure forget the keyboard commands all the time:

OSX SnowLeopard: switch audio


someone just told me: if you have the volume icon in your menubar (ie. this can be turned on/off in the audio preference panel) option-click the speaker icon & it will show you a menu to change input/output on all your audio devices.



this is something I've always wanted. Someone even created a little menubar app to do the same thing (well, it does a bit more really) - so I imagine it's a recent Mac addition. Apple have a long history of additions to the UI like this, stretching basic into System 7 days & it often makes 3rd-party accessories no longer relevant or necessary. I guess it's a risky market - adding functionality that is sort of 'obvious' (but is missing) - your app might suddenly become obselete.

Centos 4: install Ruby, gem & mechanize

what's out there 'in the field' is rarely the latest & greatest version of anything. Given the necessarily arcane ways that software is packaged for varieties of linux (wtf is irb a separate package?) - having 'the latest' version of your OS distro usually only means that you can actually get packages for it:

anyway -  you want to install Ruby & gem on an older centos box.

1. Use the instructions here to get ruby & gem. These are GOOD instructions - as they seem to work across several Centos versions.

2. update gem: 'gem update --system'

you want to install the 'mechanize' gem for some web-scraping, first install libxslt using yum - this should pull in all the dependencies like libxml2 etc.

There's a set of discussions about installing mechanize on ubuntu here.