james-trayford / strauss

Sonification Tools and Resources for Analysis Using Sound Synthesis
Apache License 2.0
33 stars 4 forks source link

Help request. #31

Open GabrieleBattaglia opened 1 month ago

GabrieleBattaglia commented 1 month ago

Dear DEVs team. This is an help request, not a bug and not an issue. I apologize for that and I'm going to close it immediately after your reply, both negative or positive. Unfortunately I'm just a beginner programmer with Python and as far as I'm reading from the doc, your beautiful project is too much complicated to me, or, at least it will take lots of time to be understood and managed by me at my present skill level. Said that, I need for a very simple 1d sonification tool that probably do not involve numpy, matplotlib or other complicated libs. I just need to sonify a serie of data using panning and pitch. I'm going to describe here what I need and if some of you has time and efford, maybe you can help me to realize it and also consider it as a very simple exercise for beginners like I am. If this goes out from your duty, absolutely no problem and I beg your perdon for the stolen time. Here's the description:


I need to develop a Python function with the following characteristics: Python 3.11 language, Windows 11 operating system, and using the strauss library.

The function will receive as input a list of float values. This list must have a minimum length of 5 values: if there are fewer, the function will return the message "data series too short"; if the values are not floats, an attempt will be made to convert them to floats, and if not possible, no output will be produced.

It will also receive a duration value that specifies the total duration in milliseconds of the sound output.

It will also receive a boolean called ptm (portamento), false by default.

It will also receive a float value, vol, which will indicate the output volume between 0.1 and 1.

A sinusoidal oscillator will be created whose starting frequency will be equal to the average of the values in the received list. However, this average will be scaled in relation to a working frequency range that will go from the frequency of the C note of the second octave, i.e., 65.41Hz, to that of a C note of the 8th octave, equal to 4186.01Hz.

Each value in the list will therefore produce a change in the oscillator's pitch that will last for the time resulting from the number of values in the list divided by the overall duration of the output to be produced.

Thanks to stereo panning, the sound produced will start from the left channel (at the beginning) and gradually move to the right channel, taking up all the time during which the output is produced. That is, if the sound produced lasts 12.3 seconds, the transition from extreme left to extreme right of the stereo panning will take exactly 12.3 seconds.

The sound will be generated and produced on the fly, i.e., without being saved to a file.

The timing in the pitch change must be as precise as possible, as the function may be passed lists containing even millions of float values.

If portamento is false, the pitch change will occur in jumps from one frequency to the next; in case of portamento True, the change will occur gradually, but always respecting the time assigned to that specific jump.

Then the function will return control to the main program flow.


Thanks for reading. Gabe.