csound-expression-4.6: library to make electronic music

Safe HaskellNone
LanguageHaskell98

Csound.Control.Gui

Contents

Description

GUI (Graphical User Interface) elements are handy to change the parameters of the sound in real time. It includes sliders, knobs, rollers, buttons and other widgets.

A GUI element consists of two parts. They are view (how it looks) and logic (what's going on with it). For example a slider can be horizontal or vertical or green or yellow or small or big. It's the view of the slider. And a slider can produce a continuous signal within the given interval. It's a logic of the slider.

Let's talk about the view. The view is divided on two parts:

  • where element is placed or Layout.
  • all other properties or just Properties.

The layout is defined with very simple functions. There are vertical and horizontal grouping of the elements. We can scale the element within the group and include an empty space in the group. Everything is aligned (see Csound.Gui.Layout). Other properties include colors, fonts (size and type), borders, specific properties of the widgets (see Csound.Gui.Props).

Let's consider the logic. The logic consists of three parts:

A widget can react on values, produce values or do something useful. There are special types of widgets:

  • Source - they produce values only
  • Sink - they consume values only
  • Display - something is going on inside them (for example, it can show a "hello world" message)

Widgets can be simple and compound. Simple widgets are primitive elements (sliders, knobs, rollers, buttons). We have a special constructors that produce simple widgets (see Csound.Gui.Widget). Compound widgets glue together several widgets. That is the view contains several elements and all of them involved in the logic of the widget.

Synopsis

Gui

data Gui :: *

A visual representation of the GUI-element.

type Widget a b = SE (Gui, Output a, Input b, Inner)

A widget consists of visible element (Gui), value consumer (Output) and producer (Input) and an inner state (Inner).

type Input a = a

Widgets that produce something has inputs.

type Output a = a -> SE ()

Widgets that consume something has outputs.

type Inner = SE ()

Widgets that just do something inside them or have an inner state.

type Sink a = SE (Gui, Output a)

A consumer of the values.

type Source a = SE (Gui, Input a)

A producer of the values.

type Display = SE Gui

A static element. We can only look at it.

type SinkSource a = SE (Gui, Output a, Input a)

widget :: SE (Gui, Output a, Input b, Inner) -> Widget a b

A widget constructor.

sink :: SE (Gui, Output a) -> Sink a

A consumer constructor.

source :: SE (Gui, Input a) -> Source a

A producer constructor.

display :: SE Gui -> Display

A display constructor.

mapSource :: (a -> b) -> Source a -> Source b

A handy function for transforming the value of producers.

mapGuiSource :: (Gui -> Gui) -> Source a -> Source a

A handy function for transforming the GUIs of producers.

mhor :: Monoid a => [Source a] -> Source a

Horizontal grouping of widgets that can produce monoidal values.

mver :: Monoid a => [Source a] -> Source a

Vertical grouping of widgets that can produce monoidal values.

msca :: Double -> Source a -> Source a

Scaling of widgets that can produce values.

Panels

panel :: Gui -> SE ()

Renders the GUI elements on the window. Rectangle is calculated automatically (window doesn't listens for keyboard events).

win :: String -> (Int, Int) -> Gui -> SE () Source

Creates a window with the given name, size and content

win name (width, height) gui

panels :: [Gui] -> SE ()

Renders a list of panels.

panelBy :: String -> Maybe Rect -> Gui -> SE ()

Renders the GUI elements on the window. We can specify the window title and rectangle of the window.

keyPanel :: Gui -> SE ()

Renders the GUI elements on the window. Rectangle is calculated automatically (window listens for keyboard events).

keyWin :: String -> (Int, Int) -> Gui -> SE () Source

keyPanels :: [Gui] -> SE ()

Renders a list of panels. Panels are sensitive to keyboard events.

keyPanelBy :: String -> Maybe Rect -> Gui -> SE ()

Renders the GUI elements on the window. We can specify the window title and rectangle of the window. Panesls are sensitive to keyboard events.

Re-exports

Lifters

An easy way to combine visuals for sound sources.

lift1 :: (a -> b) -> Source a -> Source b Source

The shortcut for mapSource.

hlift2 :: (a -> b -> c) -> Source a -> Source b -> Source c Source

Combines two sound sources. Visuals are aligned horizontally and the sound sources a grouped with the given function.

vlift2 :: (a -> b -> c) -> Source a -> Source b -> Source c Source

Combines two sound sources. Visuals are aligned vertically and the sound sources a grouped with the given function.

hlift3 :: (a -> b -> c -> d) -> Source a -> Source b -> Source c -> Source d Source

The same as hlift2 but for three sound sources.

vlift3 :: (a -> b -> c -> d) -> Source a -> Source b -> Source c -> Source d Source

The same as vlift2 but for three sound sources.

hlift4 :: (a -> b -> c -> d -> e) -> Source a -> Source b -> Source c -> Source d -> Source e Source

The same as hlift2 but for four sound sources.

vlift4 :: (a -> b -> c -> d -> e) -> Source a -> Source b -> Source c -> Source d -> Source e Source

The same as vlift2 but for four sound sources.

hlift5 :: (a1 -> a2 -> a3 -> a4 -> a5 -> b) -> Source a1 -> Source a2 -> Source a3 -> Source a4 -> Source a5 -> Source b Source

The same as hlift2 but for five sound sources.

vlift5 :: (a1 -> a2 -> a3 -> a4 -> a5 -> b) -> Source a1 -> Source a2 -> Source a3 -> Source a4 -> Source a5 -> Source b Source

The same as vlift2 but for five sound sources.

Lifters with visual scaling

hlift2' :: Double -> Double -> (a -> b -> c) -> Source a -> Source b -> Source c Source

It's just like the hlift2 but two more parameters change visual scaling of the widgets.

vlift2' :: Double -> Double -> (a -> b -> c) -> Source a -> Source b -> Source c Source

It's just like the vlift2 but two more parameters change visual scaling of the widgets.

hlift3' :: Double -> Double -> Double -> (a -> b -> c -> d) -> Source a -> Source b -> Source c -> Source d Source

The same as hlift2' but for three sound sources.

vlift3' :: Double -> Double -> Double -> (a -> b -> c -> d) -> Source a -> Source b -> Source c -> Source d Source

The same as vlift2' but for three sound sources.

hlift4' :: Double -> Double -> Double -> Double -> (a -> b -> c -> d -> e) -> Source a -> Source b -> Source c -> Source d -> Source e Source

The same as hlift2' but for four sound sources.

vlift4' :: Double -> Double -> Double -> Double -> (a -> b -> c -> d -> e) -> Source a -> Source b -> Source c -> Source d -> Source e Source

The same as vlift2' but for four sound sources.

hlift5' :: Double -> Double -> Double -> Double -> Double -> (a1 -> a2 -> a3 -> a4 -> a5 -> b) -> Source a1 -> Source a2 -> Source a3 -> Source a4 -> Source a5 -> Source b Source

The same as hlift2' but for five sound sources.

vlift5' :: Double -> Double -> Double -> Double -> Double -> (a1 -> a2 -> a3 -> a4 -> a5 -> b) -> Source a1 -> Source a2 -> Source a3 -> Source a4 -> Source a5 -> Source b Source

The same as vlift2' but for five sound sources.