Package aldrin :: Module utils
[show private | hide private]
[frames | no frames]

Module aldrin.utils

Provides utility functions needed all over the place, which have no specific module or class they belong to.
Function Summary
int bn2mn(v)
Converts a Buzz note value into a MIDI note value.
float buffersize_to_latency(bs, sr)
Translates buffer size to latency.
str byte2str(p, v)
Translates a Buzz byte value into a hexstring ready to be printed in a pattern view.
float db2linear(val, limit)
Translates a dB volume to a linear amplitude.
  error(parent, msg)
Shows an error message dialog.
str filenameify(text)
Replaces characters in a text in such a way that it's feasible to use it as a filename.
str filepath(path)
Translates a path relative to a base dir into an absolute path.
int fixbn(v)
Occasionally, invalid note inputs are being made, either by user error or invalid paste or loading operations.
str format_time(t)
Translates a time value into a string of the format "h:mm:ss:ms".
  from_hsb(h, s, b)
Converts hue/saturation/brightness into red/green/blue components.
str get_root_folder_path()
Returns the base folder from which this script is being executed.
bool is_frozen()
Determines whether the application is being executed by a Python installation or it is running standalone (as a py2exe executable.)
float linear2db(val, limit)
Translates a linear amplitude to a dB volume.
int mn2bn(v)
Converts a MIDI note value into a Buzz note value.
str note2str(p, v)
Translates a Buzz note value into a string of the format "NNO", where NN is note, and O is octave.
str prepstr(s)
prepstr ensures that a string is always ready to be displayed in a GUI control by wxWidgets.
  read_int(f)
Reads an 32bit integer from a binary file.
  read_string(f)
Reads a pascal string (32bit len, data) from a binary file.
int roundint(v)
Rounds a float value to the next integer if its fractional part is larger than 0.5.
str switch2str(p, v)
Translates a Buzz switch value into a hexstring ready to be printed in a pattern view.
float ticks_to_time(ticks, bpm, tpb)
Translates positions in ticks as returned by zzub to time values.
  to_hsb(r, g, b)
Converts red/green/blue into hue/saturation/brightness components.
str word2str(p, v)
Translates a Buzz word value into a hexstring ready to be printed in a pattern view.
  write_int(f, v)
Writes a 32bit integer to a binary file.
  write_string(f, s)
Writes a pascal string (32bit len, data) to a binary file.

Function Details

bn2mn(v)

Converts a Buzz note value into a MIDI note value.
Parameters:
v - Buzz note value.
           (type=int)
Returns:
MIDI note value.
           (type=int)

buffersize_to_latency(bs, sr)

Translates buffer size to latency.
Parameters:
bs - Size of buffer in samples.
           (type=int)
sr - Samples per second in Hz.
           (type=int)
Returns:
Latency in ms.
           (type=float)

byte2str(p, v)

Translates a Buzz byte value into a hexstring ready to be printed in a pattern view.
Parameters:
p - A plugin parameter object.
           (type=zzub.Parameter)
v - A Buzz byte value.
           (type=int)
Returns:
A 2-digit hexstring or ".." for no value.
           (type=str)

db2linear(val, limit=-48.0)

Translates a dB volume to a linear amplitude.
Parameters:
val - Volume in dB.
           (type=float)
limit - If val is lower than limit, 0.0 will be returned.
           (type=float)
Returns:
Linear amplitude.
           (type=float)

error(parent, msg)

Shows an error message dialog.

filenameify(text)

Replaces characters in a text in such a way that it's feasible to use it as a filename. The result will be lowercase and all special chars replaced by underscores.
Parameters:
text - The original text.
           (type=str)
Returns:
The filename.
           (type=str)

filepath(path)

Translates a path relative to a base dir into an absolute path.
Parameters:
path - Relative path to file.
           (type=str)
Returns:
Absolute path to file.
           (type=str)

fixbn(v)

Occasionally, invalid note inputs are being made, either by user error or invalid paste or loading operations. This function fixes a Buzz note value so it has always a correct value.
Parameters:
v - Buzz note value.
           (type=int)
Returns:
Corrected Buzz note value.
           (type=int)

format_time(t)

Translates a time value into a string of the format "h:mm:ss:ms".
Parameters:
t - Relative time value.
           (type=float)
Returns:
String of the format "h:mm:ss:ms".
           (type=str)

from_hsb(h=0.0, s=1.0, b=1.0)

Converts hue/saturation/brightness into red/green/blue components.

get_root_folder_path()

Returns the base folder from which this script is being executed. This is mainly used for windows, where loading of resources relative to the execution folder must be possible, regardless of current working directory.
Returns:
Path to execution folder.
           (type=str)

is_frozen()

Determines whether the application is being executed by a Python installation or it is running standalone (as a py2exe executable.)
Returns:
True if frozen, otherwise False
           (type=bool)

linear2db(val, limit=-48.0)

Translates a linear amplitude to a dB volume.
Parameters:
val - Linear amplitude between 0.0 and 1.0.
           (type=float)
limit - If amplitude is zero or lower, limit will be returned.
           (type=float)
Returns:
Volume in dB.
           (type=float)

mn2bn(v)

Converts a MIDI note value into a Buzz note value.
Parameters:
v - MIDI note value.
           (type=int)
Returns:
Buzz note value.
           (type=int)

note2str(p, v)

Translates a Buzz note value into a string of the format "NNO", where NN is note, and O is octave.
Parameters:
p - A parameter object. You can supply None here if the value is not associated with a plugin parameter.
           (type=zzub.Parameter)
Returns:
A string of the format "NNO", where NN is note, and O is octave, or "..." for no value.
           (type=str)

prepstr(s)

prepstr ensures that a string is always ready to be displayed in a GUI control by wxWidgets.
Parameters:
s - Text to be prepared.
           (type=str)
Returns:
Correctly encoded text.
           (type=str)

read_int(f)

Reads an 32bit integer from a binary file.

read_string(f)

Reads a pascal string (32bit len, data) from a binary file.

roundint(v)

Rounds a float value to the next integer if its fractional part is larger than 0.5.
Parameters:
v
           (type=float)
Returns:
int

switch2str(p, v)

Translates a Buzz switch value into a hexstring ready to be printed in a pattern view.
Parameters:
p - A plugin parameter object.
           (type=zzub.Parameter)
v - A Buzz switch value.
           (type=int)
Returns:
A 1-digit hexstring or "." for no value.
           (type=str)

ticks_to_time(ticks, bpm, tpb)

Translates positions in ticks as returned by zzub to time values.
Parameters:
ticks - Tick value as returned by zzub.
           (type=int)
bpm - Beats per minutes.
           (type=int)
tpb - Ticks per beats.
           (type=int)
Returns:
Relative time value.
           (type=float)

to_hsb(r, g, b)

Converts red/green/blue into hue/saturation/brightness components.

word2str(p, v)

Translates a Buzz word value into a hexstring ready to be printed in a pattern view.
Parameters:
p - A plugin parameter object.
           (type=zzub.Parameter)
v - A Buzz word value.
           (type=int)
Returns:
A 4-digit hexstring or "...." for no value.
           (type=str)

write_int(f, v)

Writes a 32bit integer to a binary file.

write_string(f, s)

Writes a pascal string (32bit len, data) to a binary file.

Generated by Epydoc 2.1 on Sun Feb 4 18:01:14 2007 http://epydoc.sf.net