Topic: Setting Random Seed in command line interface

Calling ./Pianoteq 8 --list-param shows that Condition can be set from 0 to 10.00. How do I set the random seed for condition?

A separate question, is it possible to use the randomize (dice) button on the command line?

Thank you!

Re: Setting Random Seed in command line interface

Are you using windows or linux?

Pianoteq Pro - Bechstein - Blüthner - Grotrian - K2 - Kremsegg 1 & 2 - Petrof - Steingraeber - Steinway B & D - YC5
Kawai CL35 & MP11

Re: Setting Random Seed in command line interface

Linux, does that matter?

Re: Setting Random Seed in command line interface

Anyone knows? If it's not possible, that would be good to know too!

Re: Setting Random Seed in command line interface

Sorry I forgot about this.
I was asking the OS because there are some ways to generate random numbers in the console. So you could write a little bash script or, in windows, a .bat file. But I think it would be much easier to write a Python script (could be a little C program, too).
The most complicated part is to manage the spaces in the folder and file names, I managed to make it work but I don't understand why it works now, neither the reason it did not work at the first try. May be in your distro you'll need to fiddle with the code.
I tested this script and works fine for me under Armbian Linux:
(it should be saved as a Python file, e.g. filename.py next to Pianoteq binary file. If not, you must add the path...)

Python code wrote:

import os
import random

randon_number = random.uniform(0, 10)  #generate a random number between 0 and 10
print(randon_number)
rounded_number = round(randon_number,2) #round the number to 2 decimals (idk if necessary)
print(rounded_number)
number_in_string = str(rounded_number)  #convert from float to string
print(number_in_string)
path_to_pt ="\"./Pianoteq 8\""  #path to PT
parameter = " --set-param Condition="+ number_in_string     #concatenate the random number
command = path_to_pt + parameter
print(command)
os.system(command)

Of course you can remove the "print" stuff.

For some reason, the same script does not work under Windows 10, this slighty modified version does work (again, I believe the culprit are the /, spaces and "" usage... in fact I first wrote it under windows and then noticed it did not work under Linux, so this is the original version):


Python code wrote:

import subprocess
import random


randon_number = random.uniform(0, 10)  #generate a random number between 0 and 10
print(randon_number)
rounded_number = round(randon_number,2) #round the number to 2 decimals (idk if necessary)
print(rounded_number)
number_in_string = str(rounded_number)  #convert from float to string
print(number_in_string)
path_to_pt ="C:\\Program Files\\Modartt\\Pianoteq 8/Pianoteq 8.exe --set-param Condition="  #path to PT
command = path_to_pt + number_in_string     #concatenate the random number
print(command)
subprocess.run(command)

I hope it helps,
Marcos

Last edited by marcos daniel (03-05-2024 03:59)
Pianoteq Pro - Bechstein - Blüthner - Grotrian - K2 - Kremsegg 1 & 2 - Petrof - Steingraeber - Steinway B & D - YC5
Kawai CL35 & MP11

Re: Setting Random Seed in command line interface

Thanks for the reply marcos! This doesn't vary the random seed though, so the condition would always be one of 10 values.

Re: Setting Random Seed in command line interface

hagagogu wrote:

Thanks for the reply marcos! This doesn't vary the random seed though, so the condition would always be one of 10 values.

I assume you are running Pianoteq from the command line. If so, run "pianoteq --help" and see if there is an option there for what you are trying to do. If not, there is likely no solution, but you could contact Modartt directly to verify.

Re: Setting Random Seed in command line interface

hagagogu wrote:

Thanks for the reply marcos! This doesn't vary the random seed though, so the condition would always be one of 10 values.

Since English is not my native language, maybe I didn't understand correctly what a random seed is. In any case, the possible values the script gives are 0, 0.01, 0.02, ..., 9.98, 9.99, 10, which are taken pseudo-randomly.

I asked Bing AI... in Windows this could be done by the following commands in the PowerShell:

PS wrote:

cd 'C:\Program Files\Modartt\Pianoteq 8\'
$random_number = Get-Random
echo $random_number
$divisor = 214748364.7
$condition = $random_number/$divisor
echo $condition
& '.\Pianoteq 8.exe' --set-param Condition=$condition

The description is as follows:
cd 'C:\Program Files\Modartt\Pianoteq 8\': change the actual directory to Pianoteq's
$random_number = Get-Random: gets a random number between 0 and 2147483647, which is 2^31-1
echo $random_number: just prints the number to the screen, it is not necessary
$divisor = 214748364.7: 2147483647/10; in order to get a number between 0 and 10
$condition = $random_number/$divisor: this calculation will 'normalize' the random number between 0 and 10
echo $condition: just check the result
& '.\Pianoteq 8.exe' --set-param Condition=$condition: runs Pianoteq with the condition

All this can be run without typing each time by saving it on a text file with the extension .ps1 (the extension of the Windows' PowerShell).

I have also asked the AI for Linux, but I can't post it here since I don't know if the answer works (I must confess with shame that I have stopped using Linux lately, and at this moment I do not have the devices on which I run it on hand). But if this is what you need, you can try and post the results here...
Marcos

Pianoteq Pro - Bechstein - Blüthner - Grotrian - K2 - Kremsegg 1 & 2 - Petrof - Steingraeber - Steinway B & D - YC5
Kawai CL35 & MP11