My google-fu is still strong (and Tunepal ramblings)

Google-Fu : (informal) Skill in using search engines (especially Google) to quickly find useful information on the Internet.

I was thinking of a famous piece of music, but what was it?

Whistling it, while using Shazam or Tunepal, didn’t work.

So I googled “well known classical part repeats sped up and transposes”

The second link was a Reddit link named : “Need help finding a song that starts very slow and builds to be frantic!”

First YT link in there: In the Hall of the Mountain King (Peer Gynt) by Edvard Grieg

Epic tune!

“In the Hall of the Mountain King” is a piece of orchestral music composed by Edvard Grieg in 1875 as incidental music for the sixth scene of act 2 in Henrik Ibsen’s 1867 play Peer Gynt. It was originally part of Opus 23 but was later extracted as the final piece of Peer Gynt, Suite No. 1, Op. 46.

I’ve used Tunepal many times, it’s great for folkies!

Sometimes it works also on classical pieces, because they were arranged into folk music.

https://tunepal.org/

I bought the Android app, because I liked it so much.

Tunepal is a search-by-playing search engine for traditional Irish, Welsh, Scottish, Breton, American marching band and Canadian tunes.
By playing a 12-second extract from a traditional tune on an instrument such as the flute or fiddle, you can:

  • Retrieve score matches from a database of over 24,000 music scores
  • View and playback, share and download the score
  • Find and play other recordings of the tune from a collection of over 30 million recordings

Tunepal is a search-by-playing search engine for traditional Irish, Welsh, Scottish, Breton, American marching band and Canadian tunes.

On the Record page, click the Tunepal logo or tap the screen if your computer has a touch screen. Start playing straight away. Don’t wait for the countdown to complete. Tunepal works best if there is no silence at the start of the recording.

Tunepal works best with “legato” style instruments such as the tin-whistle, flute, concertina, accordion, pipes and fiddle. It doesn’t work very well with “plucked string” instruments such as the banjo and harp.

To find a tune using Tunepal, first make sure you have a PC microphone connected to your computer or use the phone app

If your instrument uses a different “fundamental note” to the usual D (for example you are playing a C flute) or you are playing a tune in an unusual key, then you can adjust the transcription algorithm by choosing a different “fundamental” from the settings page.

You can filter the search results from the settings page to limit searches to certain tunebooks or time signatures.

Home Assistant and Harmony Hub Scripts

I’ve got a Logitech Harmony Hub to IR control devices.

When adding this to your home assistant, you initially only get the Activities.

But I want to add single button presses.
I was going to re-visit my IR remote project.
(The IR blaster and the IR wemos, see previous posts)

Thanks to Duncan I had a second look at this solution

Check the files using the file editor.
Search for /homeassistant/harmony_xxxxxxxx.conf

It will show the Hub devices and their capabilities.

Short example below

{
    "Activities": {
        "-1": "PowerOff",
        "42652474": "Watch TV",
        "43054933": "Squeeze",
        "43054959": "Watch Netflix",
        "43072690": "Switch",
        "43073688": "Spotify",
        "43557114": "Kodi",
        "49494467": "Tv on",
        "52476284": "Boxon",
        "52476285": "Boxoff"
    },
    "Devices": {
        "Google Chromecast": {
            "commands": [],
            "id": "67134460"
        },
        "LG TV": {
            "commands": [
                "PowerOff",
                "PowerOn",
                "PowerToggle",
                ".",
                "-",
                "0",
 -----------8<----------------------------- SNIP SNAP
               "SportsMode"
            ],
            "id": "67134658"
        },
        "Onkyo AV Receiver": {
            "commands": [
                "PowerOff",
                "PowerOn",
 -----------8<----------------------------- SNIP SNAP
                "VolumeLevelUp5Step"
            ],
            "id": "67134459"
        },
        "arcadyan DVR": {
            "commands": [
                "PowerToggle",
 -----------8<----------------------------- SNIP SNAP
                "TV"
            ],
            "id": "67134775"
        }
    }
}

Lets create a Script for this

See the IDs above to refer to commands below.

alias: Netflix
sequence:
  - service: remote.send_command
    target:
      device_id: 7e82a825decabedbc98a0b5ce2ac5d78
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 1.2
      command: PowerOn
      device: "67134658"
  - service: remote.send_command
    metadata: {}
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 0
      command: InputStb/Dvr
      device: "67134459"
    target:
      device_id: 7e82a825decabedbc98a0b5ce2ac5d78
  - service: remote.send_command
    metadata: {}
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 0
      command: Netflix
      device: "67134658"
    target:
      device_id: 7e82a825decabedbc98a0b5ce2ac5d78
mode: single

Add these scripts to buttons

type: entities
entities:
  - script.allmediaoff
  - script.netflix
  - script.tvon

Some nice google matching tests.

Step one, change your main DNS resolver to that one from your provider or 1.1.1.1 (cloudflare)

Goto https://www.hawking.org.uk/ in your browser

Check youtube, facebook and more.

Set you DNS to 8.8.8.8 (google)

Do the same (even in a incognito browser).

I haven’t seen a Hawking recommendation on YT for ages, I just checked a website with information on another machine.
And my YT stream showed …. Stephen Hawking!

Kodi camera stream push playlist

Below is a solution when you want to stream IP camera’s in Kodi/Libreelec .

You can push these commands using Nodered, Bash script or whatever.

First make some camera scripts in your profile directory.

Examples:

# Kodi on Linux/Raspberry
# Place a file cam1.m3u in .kodi/userdata/profiles/(kodiprofile)/playlists/video/
rtsp://admin:secretpass@192.168.1.123:88/videoMain

#and another one in cam2.m3u (another example mjpeg example)
http://192.168.1.124:8000/stream.mjpg

#For windows it is in
C:\Users\(Username)\AppData\Roaming\Kodi\userdata\profiles\(kodiprofile)\playlists\video

Enable http access in Kodi and run the playlist using curl

curl -i -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"Player.Open","params":{"options":{"shuffled":false,"repeat":"off"},"item":{"file":"special://profile/playlists/video/cam2.m3u"}},"id":"1"}' http://KODISERVERIP:8080/jsonrpc

A bash loop script

while true; do
curl -i -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"Player.Open","params":{"options":{"shuffled":false,"repeat":"off"},"item":{"file":"special://profile/playlists/video/cam1.m3u"}},"id":"1"}' http://KODISERVERIP:8080/jsonrpc
sleep 10
curl -i -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"Player.Open","params":{"options":{"shuffled":false,"repeat":"off"},"item":{"file":"special://profile/playlists/video/cam2.m3u"}},"id":"1"}' http://KODISERVERIP:8080/jsonrpc
sleep 5
done

Three channel mixer for ay-3-8910 is almost done.

At the back the 8 pin single channel lm368 amplifier.
At the front the 3 channel setup.
I still have to tweak the resistors, and potmeters.
Then I can make a permanent PCB, and figure out the connections to the 6502.

At the moment, the Arduino Nano is playing some real sound samples by using the registers of the sound chip.
The music is being played by sending the register dumps directly to the chip.

Much like i’ve been using SID register dumps to play songs in another project.

This is version 0.1 .. do not use.
If its wrong, or can do better please mail me.
Oh it needs a 1k resistor from the 20K’s to ground I think.

Watching Movies – Noticing Rik Mayall

I’m a big fan of Rik Mayall and Ade Edmondson.

(Bottom, Dangerous (Danger) Brothers, Young Ones, Black Adder etc)

I love the live shows, I’ve mentioned that before.

Today we were watching a movie, just one in our collection.
It was American Werewolf in London.
I knew there were some great practical effects in there.
(All pre CGI)

Then I saw a face a few seconds. Damn could it be Rik?

Yes it is ..

But I know he did several movies

  • Drop dead fred
  • Guest House Paradiso
  • Harry Potter

Welllllll, I more identify with Ade.

Bald, mostly interested in being drunk, and playing in a folkband. 🙂

What to do when waiting for your ribs on the smoker. (Programming some python)

This time I used a rub with the following ingredients:
Seasalt, garlic, brown sugar, mustard seeds, paprica, cilantroseeds, black pepper, red pepper, oregano, thyme and cumin.

Doing a simple 3-2-1 smoke session, so .. what to do in dose 6 hours?

Lets make something using a Sense hat and Python.
Same HAT I used for my xmas ornament thingy in our tree.

  • Generate a large maze (80×80 for now)
  • Paint the maze using colors on the SenseHat
  • Read joystick movement and scroll the maze accordingly, keeping the player in the middle

Now I have to paint my ribs with BBQ sauce, and leave it in the smoker for yet another hour. (Nice glazing)

Next steps for the maze:

Use a better way to generate (reverse backtracking as I made for my other maze thing)

Wall collision detection is nearly completed.

Better placement “birth” of player in the maze.

# # # # # # # # # # # # # # # # # # # # 

# R D . . . . . R D . . . . R R D R D # 

# D L . . . . . U D . . . . U . R U D # 

# D . . . . R R U R D . . R U U L . D # 

# R D . . . U . . . R R D U . . U L D # 

# . R D R R U . . . . . D U . . . U L # 

# . . D U L . . . . . D L U . . . . . # 

# . . R R U . . . . . R R U . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# . . . . . . . . . . . . . . . . . . # 

# # # # # # # # # # # # # # # # # # # # 

Big media button V2

Back in 2019 I made a volume/mute button using an ATtiny85.
(Digispark/trinkey thingy)

Same device as my password paster

It’s USB connection is perfect for this password paste thingy, but not for a big button like this. (even with a ugly usb extending cable)

2019 Version using digispark ATtiny85

Button is 3D printed (found on yeggi)

For my big battlestation i’m using:

The old way of flashing using Arduino IDE (for digispark)

Install Boards using : preferences, add board URL
http://digistump.com/package_digistump_index.json

Note: There being no regular USB device, you need to add some udev rules.
cat /etc/udev/rules.d/digispark.rules
SUBSYSTEM==”usb”, ATTR{idVendor}==”16d0″, ATTR{idProduct}==”0753″, MODE=”0660″, GROUP=”dialout”

When compiling and uploading the program, you get a message to plug in the device. See below screenshot.

Now the 2024 change.
Reason to change:

  • Want to have USB-C
  • Python to get a more flexible setup
  • I want to use more pins, so I can add LEDs and more buttons.
  • I wanted to play with my Waveshare RP2040 Zero.

This is the first setup, with same functionality as before.

Now I can add more stuff!

Putting the code on the RP2040-zero

Press boot button and insert into your pc.
Download uf2 file from here and save in RP2 drive.
https://circuitpython.org/board/waveshare_rp2040_zero/
Open Thonny, and configure interpreter to:

Download the zip file from https://github.com/adafruit/Adafruit_CircuitPython_HID
And copy only the subdirectory adafruit_hid to the drive in subdir lib

Open the file code.py from the device, and remove example hello world code.
Paste in the following code.

import rotaryio
import board
import time

import board
import digitalio
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode

but = digitalio.DigitalInOut(board.GP4)
but.direction = digitalio.Direction.INPUT
but.pull = digitalio.Pull.UP

cc = ConsumerControl( usb_hid.devices )

encoder = rotaryio.IncrementalEncoder(board.GP5, board.GP6)
last_position = 0
while True:
    position = encoder.position
    if int(last_position) < int(position):
        #print(position)
        command = ConsumerControlCode.VOLUME_DECREMENT
        cc.send(command)
    #last_position = position
    if int(last_position) > int(position):
        #print(position)
        command = ConsumerControlCode.VOLUME_INCREMENT
        cc.send(command)
    last_position = position
    if not but.value:
        command = ConsumerControlCode.MUTE
        cc.send(command)
        time.sleep(0.5)

Above code is the bare minimum, I’ll add more functionality soon.
(LEDs and more buttons)
Next and Previous Track and mode change.
From Audio to Navigation for example.

Well, learning every day

Some quotes I like to refer to:
https://www.henriaanstoot.nl/aboutme/

One of my websites was slow after the whole neighbourhood was without power for a few hours.
My lab using dual power, and a UPS went down for a few hours.

After that incident, one of my websites was slow, and it got worse with time.
But I never took the time to really look into this problem.
Until it was too much .. 8 seconds to TTFB

I’ve checked in the last month:

  • Hypervisors
  • Memory
  • CPU load
  • Docker instances
  • Reverse proxy
  • Bind DNS server
  • Iscsi storage
  • 10Gbps fibre connections
  • Database server
  • iotop latency

So, I was planning to rebuild my WordPress setup.
Meanwhile, let’s check some sites for information.

Then I came across WPCast on YouTube.
( How To Fix A Slow WordPress Site – WordPress Speed Optimization Tutorial )
Let’s watch this, while rebuilding my website.
All suggestions were in vain.

Until Query Monitor was mentioned.

I soon discovered that the resolving within my docker container was messed up!

2 http api call’s taking a long time.

Rebuild the docker container with my DNS nameserver and a second as fail back.

Fixed.

What did I learn, check all components!
Start close to the problem source.


"If something is worth doing, it's worth overdoing."