Clockworx Music Nodes - some issues to solve

Not that I know of at present, there are various nodes that will trigger playing a file, you will also need to have the system in running mode and use the Automatic Play node rather than the manual one. I have been away from this for a while but intend to get back to it now other issues in my life are looking more resolved.

The first thing to do is to upgrade to 2.9, this is going to be a big chuck of work and will take some time… Once that is done I need to start a Wiki explain how the system works! This will also be a bit project as there are so many nodes. I should start with a basic “How to get Started” section as this is important in being able to use Clockworx.

Actually the first thing to do is to get myself familiar with this project again as It has slipped from my ageing brain!

Cheers, Clock.

PS. Welcome to DevTalk!

EDIT:

You can see here that the Auto Speaker node has a Boolean input, so if you send a message to this using other nodes you can trigger when it plays, You also need to have the Execution mode set to either Frame Change, or Timed so the system executes…

Hope this helps in the meantime until I get myself organised with this once more…

So, here is the new Object Data node that will send the location, rotation or scale transform of an object. Here I am sending it to a Compare node to produce a Boolean:

In this case if the X location is greater than 0, the sound file will be played.

Cheers, Clock.

EDIT:

I have checked this with Blender 2.9x and all works well as expected!

2 Likes

I have found some time to get back to this and have made a number of changes, a picture:

This shows a primitive start to a Mixer Desk. I have adapted the Object input and Object Data nodes so they can now send location, rotation and scale values on the three Global axes to other nodes. This I have used to set the volume of the file being played.

After much frustration I have finally worked out how to properly read the values from either the socket itself, or a connected node. Believe it or not you must check these in the right order, i.e. connected node then it’s own value, or it gives what appear to be random numbers…

I also modified some of the filters so they have a Dry and Wet volume input, this allows the user to mix Wet and Dry output, or simply bypass the filter by setting Wet output to 0.

The curious little pink object is being used to determine the start and duration of the sound file being played - X location sets the start, Z location sets the duration. If Z location is not greater than 0 the output speaker is disabled btw.

Thee changes have been uploaded to GitHub, but I still have not made a release, so install it as per the Readme on the GitHub opening page.

Still a long way to go with this in terms of finishing the function Todo list (including a Granuliser), cleaning the code and adding all the DocStrings, etc. Testing on 2.93 is going well, but I will wait for official release before completing this job. Thanks must go to my friend in Italy for keeping me going with this and providing much needed technical input on the DAW side.

Cheers, Clock. :grin:

3 Likes

I’ve started on the Wiki, comments, including “What the fudge is that Clock?”, or “Is that the best you can do” most welcome.

Cheers, Clock. :rofl:

3 Likes

Well, I have managed to record a little GIF:

test

Which shows my mini digger operating. Not too impressive really, until you realise that it was controlled in real time by my Korg nanoKontrol2…

Two buttons move it back and forth and rotate the body and three sliders control the position of and rotation of the bucket.

Here’s the NodeTree:

I might get around to explaining how to do this on the Wiki soon… :joy:

Cheers, Clock. :upside_down_face:

2 Likes

Something else to show you, thanks to @tintwotin for this piece of magic:

Blender and Audacity happily working together on my Mac.

Cheers, Clock.

3 Likes

Hi Clock,

Well, I know you are old and senile, but you could have referenced the excellent work by @tintwotin, so I’ll do it for you:

Cheers, Clock. :rofl:

PS. Just wrote this node to take the Float value only from a Live! MIDI feed so you can set any Float Input Socket in the NodeTree with a MIDI Controller, or Keyboard:

The lower one uses a Slider, the upper one uses two buttons on my Korg nanoKontrol2.

Just to let everyone who’s interested know (yes both of you :rofl:) I have now tested CMN against Blender 2.93 LTS and all works well. The install for PyGame is changed slightly from previous versions, but I have amended the README and Wiki Install Page to reflect these changes.

Cheers, Clock. :upside_down_face:

3 Likes

Hello sir,

I am a computer graphics student working on an animation project: animating a robot to play the drums of the song “half-alive’” by the band still feel.

I think that using a midi file to drive the animation would save a lot of time for the keyframing.

I tried using the animation nodes addon, but it can’t read my midi file, so I wanted you to know that I am grateful for your work !

First, Welcome to DevTalk!

OK, you mean something like this:

This was an early attempt I did some 5 years ago, its a bit clunky, but is getting there. Nowadays I would use my own Add-on, still under development, but you get the idea! Mine needs the MIDI file in .csv format, Animation nodes needs it as a raw MIDI file. Have you looked at the documentation for Animation Nodes here:

Let me know if there is any more help I can give you, but the first thing is to get AN to read your MIDI file, what is going wrong here? What error messages are you getting. Try a simple drum track first, that may be the way to go…

It’s a good idea to run Blender from a terminal, you see far more error messages that way, You need to navigate the terminal to the location of the executable for Blender then run it as ./Blender.exe if you are on windows, I think, I am Mac and Linux only…

Yep, my first music animations took months of work… later ones take very little time, there are a few on my YouTube and Vimeo channels.

This one:

The drums are animated as the pink cylinders, using shapekeys. Bass is the shapekeys on the grey shape. I think I have referenced some of the videos in earlier posts.

Cheers, Clock.

1 Like

Thanks !

Yes this is exactly the kind of thing I’m aiming to do.

I did read the animation node midi documentation and followed the steps to explore the tracks, however animation node seems to think that the tracks are empty (list - length:0).

I tried to replicate the issue with another midi file but couldn’t.

Since my midi file can be read in other software, my guess is that the data structure of the file may be non-standard, however after converting it to CSV (with midicsv-1.1) I didn’t notice anything weird in it, so I’m not sure what the issue is here.

Here’s a screenshot of the issue (in blender 2.93.2):

So instead I’m using the csv version.

I installed your addon (Clockworx Music Editor) but I didn’t work out how to use the csv file … the wiki explain how to use sound files and mention midi but didn’t elaborate, I’m guessing it’s because it’s a work in progress ^^

As a test, I first created a MIDI Analyser node to read the midi.csv, set my csv file as the input but I get a KeyError:“Track Name” when I click on “Analyse File” :

I get the same error with the other midi file (converted to CSV) which worked with Animation Node so I’m guessing that the issue is not coming from the file, I probably need to do something else to make it work but I’m not sure what…

I really want to use your addon so any advice is welcome :slight_smile:

I will try running blender from a terminal, thanks for the tip !

I couldn’t put more than two link in my post, sorry ! Here are the midi files (and CSV version) I used : midi - Google Drive

EDIT :
I followed your advice, animation nodes do not throw an error in the console but the clockworx music addon does :

Python: Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\clockworx-music\operators\CM_OT_AnalyseMidiFile.py", line 23, in execute
    cm_node.track_name = cm.data_dict['Track Name']
KeyError: 'Track Name'

location: <unknown location>:-1

OK, I’ll. take a look later today.

I am guessing there is a non-standard track in there, so it’s not analysing the file. It seem to have picked up the BPM, Pulse, Time Sig & Tempo tho…

OK, your file does not conform to MIDI standard!

Yours is on the left, a good one is on the right. Your should look at the number on the left, the file descriptor information is always in Track 1 and should contain the MIDI tempo, time sig, etc. Then the individual tracks should be in Track 2 onwards. You file has all the music info in Track 1. So if you look at mine, Track 1 has an “End Track” time offset of 4055040, then Track 2 starts, these are the instrument tracks after this, each one of which should have an “End Track” time offset.

Note-on and Note-off entries should never be in Track 1 as this is not for the music itself. This is why neither the AN, or Clockworx Music addons can read the file, I will add a trap for that in the code at some point soon and add an error message that tells you the file is corrupt. Also yours has a very low Pulse value, this is the last entry in the first Header line, this will not give you very accurate time info.

In my file you will find several tracks numbered 2 onwards, for the separate instruments, I can’t upload it to this site, but if you send me a private message with your email (don’t put your email address on here) I can send you this file.

Here is an example of what the node should look like:

And a screenshot from the terminal, note I have checked “View in Terminal” on the Info Node.

Cheers, Clock.

EDIT, the same problem exists in sample.csv file…

It’s worth noting that if every instrument was in the same Track, like Track 1, the programme would have no way of splitting individual instruments from the MIDI file.

EDIT 2, I tried loading your file in Reason DAW, https://www.reasonstudios.com it didn’t like your MIDI file at all!!! it just displayed this emoji: :poop:

Apologies for answering so late, I’m going through a nasty burnout.

I understand way better how midi file works thanks to you now, thank you !

I’m a bit surprised that the sample file is not to specs since I got it from here : Mobilefish.com - A tutorial about MIDI specification. Includes examples..

I was able to sort of fix the midi file by uploading it to Online Sequencer - Upload MIDI File and then re-downloading it - it’s probably not ideal but maybe this will suffice :slight_smile:

1 Like

That’s fine, hope the burnout passes real soon!!

If I get a midi file off the net, I always pass it through Reason first, that sorts any errors or it just rejects them outright and I dump them.

Might be worth you getting a simple free DAW for this purpose. Are you in Windows, Mac or Linux. Mac has GarageBand, which is free, there are lots for Linux, I use LMMS, I don’t have Windows, but I’m sure there will be something!

Been a bit busy myself just lately, taking exams for my pilots license, which stressed me a bit as I haven’t taken an exam for nearly forty years!!

Take care, you can always contact me here for help.

Cheers, Clock.

1 Like

OK, so I have been looking at ways to load PyGame without users having to get dirty in a terminal. :open_mouth: :rofl:

And it seems that in 2.93.4 I can add this code to the __init__.py file:

import subprocess
import sys

try:
    import pip
except ImportError:
    subprocess.check_call([sys.executable, "-m", "ensurepip"])
try:
    import pygame as pg
except ImportError:
    subprocess.check_call([sys.executable, "-m", "pip", "install", 'pygame'])
finally:
    import pygame as pg

And first of all on a virgin install of Blender, it will load Pip, then add the PyGame module, lots of checking to do, by repeatedly deleting my Blender install and trying again, but it seems to be working, unless any of you smart youngsters want to tell me a better way…

Cheers, Clock.

PS. Passed my first exam for my license… and am now “Solo” status!!! The skies over the UK are no longer a safe space…

2 Likes

OK, tearing out what little hair I have left!

When I close Blender (launched from a terminal) I get this error:

Exception in module unregister(): '/Users/apple/Library/Application Support/Blender/3.0/scripts/addons/clockworx-music/__init__.py'
Traceback (most recent call last):
  File "/Users/apple/Documents/blender/blender-3.0/Blender.app/Contents/Resources/3.0/scripts/modules/addon_utils.py", line 439, in disable
    mod.unregister()
  File "/Users/apple/Library/Application Support/Blender/3.0/scripts/addons/clockworx-music/__init__.py", line 435, in unregister
    bpy.utils.unregister_class(cls)
RuntimeError: unregister_class(...):, missing bl_rna attribute from 'RNAMetaPropGroup' instance (may not be registered)

Blender quit

With version 3.0 Release Candidate, this is the code in my __init__.py

def register():

    for cls in classes:
        bpy.utils.register_class(cls)

    Scene.cm_pg = PointerProperty(type=CMSceneProperties)

    nodeitems_utils.register_node_categories("AUDIO_CATEGORIES", categories)


def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)
    nodeitems_utils.unregister_node_categories("AUDIO_CATEGORIES")

    del Scene.cm_pg

if __name__ == "__main__":
  register()

The is not the case with Blender 2.9x - I have never seen this error in 2.9x btw.

Can anyone suggest what might be wrong here, searching the 'net tells me to do exactly what I have been doing all along…

Cheers, Clock. :frowning_face:

1 Like

OK, sorted the problem, it was an error in one of the node files, I put a trap in like this:

def unregister():
    for cls in classes:
        try:
            bpy.utils.unregister_class(cls)
        except:
            print(str(cls))
    nodeitems_utils.unregister_node_categories("AUDIO_CATEGORIES")

    del Scene.cm_pg

if __name__ == "__main__":
  register()

So I could find out what was causing the problem.

Getting data from node sockets seems to have changed in 3.0, I’ve worked it out though. It will be nice once the new 3.0 API is made available!

Cheers, Clock.

2 Likes

OK, I have uploaded a modified version to my Github in Master Branch for 2.9x and created a new branch “Blender-3.0” for… well… Blender 3.0! Still finding the odd bug and things that need improving.

Cheers, Clock.

1 Like