The purpose of this chapter is to describe Pd's design and how it is supposed to work. Practical details about how to obtain, install, and run Pd are described in the next chapter. Links to more extensive guidaes (and to more theoretical information about computer music) can be found in the previous chapter.
Pd is a real-time graphical programming environment for audio and graphical processing. It resembles the Max/MSP system but is much simpler and more portable; also Pd has two features not (yet) showing up in Max/MSP: first, via Mark Dank's GEM package, Pd can be used for simultaneous computer animation and computer audio. Second, an experimental facility is provided for defining and accessing data structures.
When Pd is running, you'll see a main "Pd" window, and possibly one or more "canvases" or "patches". The main Pd window looks like this:
There are peak level and clip indicators for audio input and output; these report peak levels over all input and all output channels. Note that DC shows up as an input level; many cards have DC levels which show up in the 50s. To see an RMS audio level, select "test audio and MIDI" from the Media menu. The main window display is intended only to help you avoid clipping on input and output. You can turn the peak meters on and off using the control at lower left.
At lower right is a control to turn audio processing on and off globally. Turning audio off stops the computation and relinquishes any audio devices Pd is using. The "Media" menu is also provided, with accelerators "Control-." to turn audio computation off and "Control-/" to turn it on. When audio is on, Pd is computing audio samples in real time according to whatever patches you have open (whether they are visible or not).
The DIO (Digital I/O) error indicator flashes if there is a synchronization error for audio input or output. (But note that on some platforms Pd doesn't find out about them. If you never see red, you're probably not seeing the truth.) Click the "DIO errors" button to see a list of recent errors. This indicator should turn red whenever the computation runs late (so that the DAC FIFOs fill and/or the ADC FIFOs empty) or if audio input and output are not running at the same rate. See audio and MIDI support .
The bottom part of the Pd window is an area for printout from objects in patches, and/or for messages from Pd itself.
Pd documents are called "patches" or "canvases." Each open document has one main window and any number of sub-windows. The sub-windows can be opened and closed but are always running whether you can see them or not. Here is a simple Pd patch:
There are four text boxes in this patch: a number box (showing zero), an object box showing "print," and two comments. The number box and the object box are connected, the number box's output to the print box's input. Boxes may have zero or more inputs and/or outputs, with the inputs on top and the outputs on bottom.
Pd's printout appears on the main "Pd" window, unless you redirect it elsewhere.
Pd patches can have four types of boxes: object, message, GUI, and comment .
You make objects by typing text into object boxes. The text is divided into atoms separated by white space. The first atom specifies what type of object Pd will make, and the other atoms, called creation arguments , tell Pd how to initialize the object. If you type for example,
the "+" specifies the class of the object. In this case the object will be the kind that carries out addition, and the "13" initializes the amount to add.
Atoms are either numbers or symbols like "+". Anything that is not a valid number is considered a symbol. Valid numbers may or may not have a decimal point (for instance, 12, 15.6, -.456), or may be written in exponential notation (such as "4.5e6", which means "4.5 multiplied by 10 six times, i.e., 4500000). Negative exponentials divide by 10 (so that 1.23e-5 comes to 0.0000123).
Non-valid numbers which are read as symbols include things like "+5" and "0..6" as well as words and names such as "Zack" or "cat". The symbols "gore", "Gore", and "GORE" are all distinct.
The text you type into an object box determines how many and what kinds of inlets and outlets the object will have. Some classes (like "+" always have a fixed arrangement of inlets and outlets, and in the case of other classes, the inlets and outlets will depend on the creation arguments.
Here for example is a simple MIDI synthesizer:
This patch mixes control objects (notein, stripnote, and ftom) with tilde objects osc~, *~, and dac~. The control objects carry out their function sporadically, as a result of one or more type of event . In this case, incoming MIDI note messages set off the control computation. The result of the computation is, when the note happens to be a "note on" (and not a "note off", to compute the frequency in cycles per second and pass it on to the oscillator ("osc~").
The second half of the patch, the osc~, *~, and dac~ objects, compute audio samples, in the same way as an analog synthesizer works. The osc~ object is acting as the interface between the two regimes, in that it takes control messages to set its frequency but talks to "*~" using an audio signal. Audio signals aren't sporadic; they are continuous streams of numbers. As a result tilde objects act under very different rules from control objects. The audio portion of the patch is always running, whether MIDI messages arrive or not. On the other hand, the function of control computations is to insert calculations between the audio computation which may change audio computation parameters such as the frequency of an oscillator.
The connections in the patch (the lines between the boxes) are also of two types: control and signal. The type of connection depends on the outlet it comes from. Signal connections are represented by thicker lines than control connections; in the patch above, the two bottom connections are signal and the others are control. In general, a control connection may be made to a signal inlet; if numbers are sent over it they are automatically converted to signals. Signal connections may not be made to control inlets; some sort of explicit conversion must be specified.
The border of a box tells you how its text is interpreted and how the box functions. Object boxes (as in the previous example) use the text to create objects when you load a patch or type text onto a new one. If you retype the text in an object box, the old one is discarded and a new one is created, using the new creation arguments. The contents of an object box describe a message which is sent to Pd to create the object.
Message boxes interpret the text as a message to send whenever the box is activated (by an incoming message or with the mouse.) The message may be sent many times while the patch is running (as opposed to object boxes whose message is used once to create the object). Instead of going straight to Pd, the message box's message (or messages) go either to the box's outlet or to other specified receiving objects. In the example below, the message box, when clicked, sends the message "21" to an object box which adds 13 to it.
The third box shown is a GUI ("graphical user interface") box. GUI boxes come in many forms including number boxes (as in this example), toggles, sliders, and so on. Whereas the appearance of an object or message box is static when a patch is running, a number box's contents (the text) changes to reflect the current value held by the box. You can also use a number box as a control by clicking and dragging up and down, or by typing values in it. (There are also shift- and alt-click actions; see getting help to find out how to look this up).
You can also create a "symbol" box which is like a number box but deals in symbols like "cat." You can type your own strings in (followed by "enter") or use it to display strings which arrive as messages to its inlet.
When you save a patch to a file, Pd doesn't save the entire state of all the objects in the patch, but only what you see: the objects' creation arguments and their interconnections. Certain data-storage objects have functions for reading and writing other files to save and restore their internal state.
Pd finds files using a path which can be specified as part of Pd's startup arguments. The path specifies one or more directories, separated by colons (semicolons if you're using windows.) Most objects which can read files search for them along the search path, but when Pd writes files they go to the directory where the patch was found.
A patch can be in edit or run mode; this really only affects how mouse clicks affect the patch. In edit mode, clicking and dragging selects and moves boxes or makes and cuts connections; in run mode clicking on boxes sends them messages which they react to in different ways. In run mode, number and message boxes can be used as controls.
You can create boxes (objects, messages, GUIs, and comments) using the "put" menu. Note the handy accelerators. Object and message boxes are empty at first; drag them where you want them and type in the text. The GUI objects (which come in several flavors) require no typing; just create and place them.
You will often find it more convenient to select a box and "duplicate" it (in the Edit menu) than to use the "Put" menu. If you select and duplicate several items, any connections between them will be duplicated as well.
Boxes in a Pd window may be selected by clicking on them. To select more than one object you may use shift-click or click on a blank portion of the window and drag the cursor to select all objects within a rectangle.
Clicking on an unselected object, message, or comment box makes the text active, i.e., ready to be text edited. (If you select using the rectangle method, the text isn't activated.) Once you've activated a text box, you may type into it (replacing the selected text) or use the mouse to change the selection.
You may also select a single connection (patch cord) by clicking on it. You can't have connections and boxes selected simultaneously.
If you select a box, a connection, or several boxes, and if you haven't made any text active, you can "delete" the selection by hitting the backspace or delete key. You can also "cut" "copy" and "paste" using menu items. Notice that pasting puts the new object(s) right down on top of the old ones.
The "duplicate" menu item performs a copy and paste with a small offset so you can see the new boxes. You can drag them together to a new place on the screen.
You can cut and paste between windows within Pd but cut/paste isn't integrated with the OS in any way. Cut/copy/paste for activated text in boxes isn't implemented yet, although in Linux at least you can "X-paste" into and out of "text" dialogs (created with the "edit text" menu item.)
To change a text item, you can select it and then edit the text. If you only click once, the entire text is selected and your typing will replace everything. Click again and drag to select a portion of the text to retype.
If there's more than a small amount of text (in a comment, for example) you might want to select the text and choose "text editor" from the Edit menu, which opens a text editing window with a copy of the text in it. Hitting "send" in that window is exactly equivalent to retyping the text into Pd; you can send it to more than one box in sequence if you want.
If you click a box and move the mouse without releasing the button this displaces the entire box. If you wish to displace a box which is already selected, first de-select the box by clicking outside it; otherwise you will be selecting text instead of moving the box.
The updated text only becomes part of the patch when you de-select the object. Changing the text in an "object" box deletes the old object and creates a new one; the internal state of the old one is lost.
To make a connection between two boxes, click on any outlet of the first one, drag toward an inlet of the second one, and release. You can release the mouse button anywhere within the target object and the connection will be made to the nearest inlet.
Connections are broken by selecting them and using "cut" or the backspace or delete key.
All the "clicking" mentioned above is done with the left mouse button. The right button, instead, gives a popup menu offering "properties," "open," and "help". (For Macintosh users who may only have one button on their mouse, double-clicking is mapped to right-click.)
Selecting "help" on an object gets a Pd patch that demonstrates how to use it. "Help" for the canvas as a whole (right-clicking outside any object) gives a list of all built-in objects.
The "open" menu item is only enabled if you right-click on a subpatch (see below) and causes Pd to open it. Ordinary subpatches may also be opened by clicking on them, but for "graph-on-parent" ones, this is the only way to do it.
The "properties" dialog allows you to change certain settings of GUI objects, or of the patch itself (by clicking outside any box.)
Control-q "quits" Pd, but asks you to comfirm the quit. To quit without having to confirm, use command-shift-Q.
In Pd, objects intercommunicate by sending messages and/or audio signals. Pd messages are sporadic, like MIDI messages or music N "Note cards."
Messages contain a selector followed by any number of arguments. The selector is a symbol, which appears in the patch as a non-numeric string with no white space, semicolons, or commas. The arguments may be symbols or numbers. Numbers in Pd are kept in 32-bit floating point, so that they can represent integers exactly between -8388608 and 8388608. (In Max, there are separate data types for integers and floating point numbers; Pd uses only float.)
When a message is passed to something (which is often an inlet of a box but could be anything that can receive a message), the selector of the message is checked against the receiver. If the receiver recognizes messages of that selector, it carries out some corresponding action. For instance, here is a "float" object:
The two rectangles at the top are usually both called "inlets" but the one at the left directs incoming messages to the "float" object itself, whereas the one at the right directs messages to an auxiliary "inlet" object. The float object proper (represented by the left-hand inlet) accepts messages with selector "float" and "bang". The right-hand inlet takes only the message selector "float". These two selectors, along with "symbol" and "list", are usually used to denote an object's main action, whatever it may be, so that objects can be interconnected with maximum flexibility.
It is possible to type messages which start with a number, which cannot be used as a selector. A single number is always given the "float" selector automatically, and a message with a number followed by other arguments is given the selector "list".
In Pd whenever a message is initiated, the receiver may then send out further messages in turn, and the receivers of those messages can send yet others. So each message sets off a tree of consequent messages. This tree is executed in depth first fashion. For instance in the patch below:
the order of arrival of messages is either A-B-C-D or A-C-D-B. The "C" message is not done until the "D" one is also, and the "A" is not done until all four are. It is indeterminate which of "B" or "C" is done first; this depends on what order you made the connections in (in Max, it's automatically sorted right to left).
Message-passing can give rise to infinite loops of the sort shown here:
Here the left-hand "+" can't finish processing until the right-hand one has been sent the result "2", which can't finish processing that until the left-hand one has been sent "3", and so on. Pd will print an error message reporting a "stack overflow" if this happens.
However, it is legal to make a loop if there is a "delay" object somewhere in it. When the "delay" receives a message it schedules a message for the future (even if the time delay is 0) and is then "finished;" Pd's internal scheduler will wake the delay back up later.
With few exceptions (notably "timer"), objects treat their leftmost inlet as "hot" in the sense that messages to left inlets can result in output messages. So the following is a legal (and reasonable) loop construct:
Here the "f" is an abbreviation for "float". Note that the "+ 1" output is connected to the right-hand inlet of "f". This "cold" inlet merely stores the value for the next time the "f" is sent the "bang" message.
It is frequently desirable to send messages to two or more inlets of an object to specify its action. For instance, you can use "+" to add two numbers; but to do it correctly you must make sure the right hand inlet gets its value first. Otherwise, when the left hand side value comes in, "+" will carry out the addition (since the left hand inlet is the "hot" one) and will add this value to whatever was previously sitting in the right hand inlet.
Problems can arise when a single outlet is connected (either directly or through arbitrarily long chains of message passing) to different inlets of a single object. In this case it is indeterminate which order the two inlets will receive their messages. Suppose for example you wish to use "+" to double a number. The following is incorrect:
Here, I connected the left inlet before connecting the right hand one (although this is not evident in the appearance of the patch.) The "+" thus adds the new input (at left) to the previous input (at right).
The "trigger" object, abbreviated "t", can be used to split out connections from a single outlet in a determinate order. By convention, all objects in Pd, when sending messages out more than one outlet, do so from right to left. If you connect these to inlets of a second object without crossing wires, the second object will get its leftmost inlet last, which is usually what you want. Here is how to use "trigger" to disambiguate the previous example:
"Cold" (non-leftmost) inlets are almost universally used to store single values (either numbers or symbols.) With the exception of "line" and "line~", these values are "sticky," i.e., once you set the value it is good until the next time you set it. (The "line" exception is for sanity's sake.)
One more question sometimes comes up in execution order, which is the order in which two messages are sent to a single "cold" inlet. In this situation, since the messages are merged, the last value to be received is the value that is used in the computation.
The first of the message boxes above contains the single number 1.5; this message has an implicit selector of "float." The second is a list with three numbers in it, and in the third, the selector is "my" and the two arguments are the number 5 and the symbol "toes."
Multiple messages may be separated by commas as shown:
Here the three messages are the numbers 1, 2, and 3, and they are sent in sequence (with no intervening time between them, as with the "trigger" object, and having depth-first consequences so that whatever chain of actions depending on "1" takes place before anything depending on "2" and so on.)
Semicolons may also separate messages. A message following a semicolon must specify a symbol giving a destination (in other words, semicolons are like commas except that they clear the "current destination" so that the next message specifies a new one). The "current destination" is at first the message box's own outlet. In the example below, the leading semicolon immediately redirects messages from the outlet to an object named "fred" (which is here a receive object), and likewise the next message is sent to "sue."
Certain other objects (Pd windows, for example, and arrays) have Pd names and can be sent messages this way. Also, the special object "pd" is defined to which you may send messages to start and stop DSP.
You can put variables in message boxes as shown below:
Here, "$1", etc., refer to the arguments of the arriving message (and aren't defined if you send a "bang" message or if you click on the message box to activate it.) Dollar sign variables are either numbers or symbols depending on the incoming message; if symbols, you may even use them to specify variable message selectors or destinations.
Using Pd you can build audio patches which can synthesize musical sounds, analyze incoming sounds, process incoming sounds to produce transformed audio outputs, or integrate audio processing with other media. This section describes how Pd treats audio signals.
Pd's audio signals are internally kept as 32-bit floating point numbers, so you have all the dynamic range you could want. However, depending on your hardware, audio I/O is usually limited to 16 or 24 bits. Inputs all appear between the values of -1 and 1; and output values will be clipped to that range. Pd assumes a sample rate of 44100 unless you override this ( in Pd's command line or in the "audio setup" dialog).
Pd can read or write samples to files either in 16-bit or 24-bit fixed point or in 32-bit floating point, in WAV, AIFF, or AU format, via the soundfiler, readsf, and writesf objects.
Audio computations in Pd are carried out by "tilde objects" such as "osc~" whose names conventionally end in a tilde character to warn you what they are. Tilde objects can intercommunicate via audio connections. When audio computation is turned on, or when you change the audio network while audio is on, Pd sorts all the tilde objects into a linear order for running; then this linear list is run down in blocks of 64 samples each; at 44100 Hz. this means the audio network runs every 1.45 milliseconds.
Inlets or outlets are configured in Pd either for messages or audio; it's an error to connect an audio outlet to a non-audio inlet or vice versa; usually these errors are detected at "sort time" when audio is started or the network changed with audio running. An object's leftmost inlet may accept both audio and messages; any other inlet is either one or the other.
The audio network, that is, the tilde objects and their interconnections, must be acyclic. If there are loops, you will see the error message at "sort time." When errors are reported at sort time there is no easy way to find the source of the error. You can build algorithms with feedback using nonlocal signal connections.
Your subpatches can have audio inlets and outlets via the inlet~ and outlet~ objects.
If you want to use a control value as a signal, you can use the sig~ object to convert it. The +~, -~, *~, /~, osc~, and phasor~ objects can be configured to take control or signal inputs.
The other direction, signal to control, requires that you specify at what moments you want the signal sampled. This is handled by the snapshot~ object, but you can also sample a signal with tabwrite~ and then get access it via tabread or tabread4 (note the missing tildes!). There are also analysis objects, the simplest of which is "env~", the envelope follower.
You can use the switch~ or block~ objects to turn portions of your audio computation on and off and to control the block size of computation. There may be only one switch~ or block~ object in any window; it acts on the entire window and all of its subwindows, which may still have their own nested switch~/block~ objects. Switch~ and block~ take a block size and an overlap factor as arguments; so for instance, "block~ 1024 4" specifies 1024 sample blocks, overlapped by a factor of 4 relative to the parent window. Switch~ carries a small computational overhead in addition to whatever overhead is associated with changing the block size.
Larger block sizes than 64 should result in small increases in run-time efficiency. Also, the fft~ and related objects operate on blocks so that setting the block size also sets the number of FFT channels. You may wish to use block sizes smaller than 64 to gain finer resolutions of message/audio interaction, or to reduce "block delay" in feedback algorithms. At the (untested) extreme, setting the block size to one allows you to write your own recursive filters.
You can use switch~ to budget your DSP computations; for instance you might want to be able to switch between two synthesis algorithms. To do this, put each algorithm in its own subpatch (which can have sub-sub patches in turn, for a voice bank for instance), and switch each one off as you switch the other one on. Beware of clicks; if you have a line~ controlling output level, give it time to ramp to zero before you switch it off or it will be stuck at a nonzero value for the next time it comes back on.
When a subpatch is switched off its audio outputs generate zeros; this costs a fairly small overhead; a cheaper way to get outputs is to use throw~ inside the switched module and catch~ outside it.
You may wish to pass signals non-locally, either to get from one window to another, or to feed a signal back to your algorithm's input. This can be done using throw~/catch~, send~/receive~, or delwrite~/delread~ pairs. Throw~ and catch~ implement a summing bus; throw~ adds into the bus and catch~ reads out the accumulated signal and zeros the bus for the next time around. There can be many throw~ objects associated with a single catch~, but a throw~ can't talk to more than one catch~. You can reset the destination of a throw~ if you want to.
Send~ just saves a signal which may then be receive~d any number of times; but a receive~ can only pick up one send~ at a time (but you can switch between send~s if you want.)
Don't try to throw~ and catch~ or send~ and receive~ between windows with different block sizes. The only re-blocking mechanisms which are well tested are inlet~ and outlet~.
When you send a signal to a point that is earlier in the sorted list of tilde objects, the signal doesn't get there until the next cycle of DSP computation, one block later; so your signal will be delayed by one block (1.45 msec by default.) Delread~ and delwrite~ have this same restriction, but here the 1.45 msec figure gives the minimum attainable delay. For non-recursive algorithms, a simple flanger for example, you might wish to ensure that your delread~ is sorted after your delwrite~. The only way to ensure this is to create the delread~ after you created the delwrite~; if things get out of whack, just delete and re-create the delread~.
Pd uses 64-bit floating point numbers to represent time, providing sample accuracy and essentially never overflowing. Time appears to the user in milliseconds.
Audio and message processing are interleaved in Pd. Audio processing is scheduled every 64 samples at Pd's sample rate; at 44100 Hz. this gives a period of 1.45 milliseconds. You may turn DSP computation on and off by sending the "pd" object the messages "dsp 1" and "dsp 0."
In the intervals between, delays might time out or external conditions might arise (incoming MIDI, mouse clicks, or whatnot). These may cause a cascade of depth-first message passing; each such message cascade is completely run out before the next message or DSP tick is computed. Messages are never passed to objects during a DSP tick; the ticks are atomic and parameter changes sent to different objects in any given message cascade take effect simultaneously.
In the middle of a message cascade you may schedule another one at a delay of zero. This delayed cascade happens after the present cascade has finished, but at the same logical time.
The Pd scheduler maintains a (user-specified) lead on its computations; that is, it tries to keep ahead of real time by a small amount in order to be able to absorb unpredictable, momentary increases in computation time. This is specified using the "audiobuffer" or "frags" command line flags (see getting Pd to run ).
If Pd gets late with respect to real time, gaps (either occasional or frequent) will appear in both the input and output audio streams. On the other hand, disk streaming objects will work correctly, so that you may use Pd as a batch program with soundfile input and/or output. The "-nogui" and "-send" startup flags are provided to aid in doing this.
Pd's "realtime" computations compete for CPU time with its own GUI, which runs as a separate process. A flow control mechanism will be provided someday to prevent this from causing trouble, but it is in any case wise to avoid having too much drawing going on while Pd is trying to make sound. If a sub-window is closed, Pd suspends sending the GUI update messages for it; but not so for miniaturized windows as of version 0.32. You should really close them when you aren't using them.
All message cascades that are scheduled (via "delay" and its relatives) to happen before a given audio tick will happen as scheduled regardless of whether Pd as a whole is running on time; in other words, calculation is never reordered for any real-time considerations. This is done in order to make Pd's operation deterministic.
If a message cascade is started by an external event, a time tag is given it. These time tags are guaranteed to be consistent with the times at which timeouts are scheduled and DSP ticks are computed; i.e., time never decreases. (However, either Pd or a hardware driver may lie about the physical time an input arrives; this depends on the operating system.) "Timer" objects which measure time intervals measure them in terms of the logical time stamps of the message cascades, so that timing a "delay" object always gives exactly the theoretical value. (There is, however, a "realtime" object that measures real time, with nondeterministic results.)
If two message cascades are scheduled for the same logical time, they are carried out in the order they were scheduled.
In an object box, as in a message box, the text specifies a message; but here the message is to be passed to Pd itself, once, and the message's effect is to create the object in question. When you open a file, all the objects created are created using their text as "creation messages." If you type a new message into an object box (or change it), the old object is destroyed and the message is used to create the new one.
The selector of the message (the first word in the message) is a selector which Pd interprets to mean which type of object to create. Any message arguments (called "creation arguments") are used to parameterize the object being created. Thus in "makenote 64 250" the selector "makenote" determines the class of object to create and the creation arguments 64 and 250 become the initial velocity and duration.
An exception is made for subpatches whose "state" is the configuration of the subpatch; as a special case, this configuration is restored when the patch is read from a file. Also, if you rename the subpatch, for instance typing "pd jane" instead of "pd spot," the contents of the patch are preserved and only the text in the object box and the window title of the subpatch are changed.
It is probably bad style to specify creation arguments ala "makenote 64 250" if you are going to override them later; this is confusing to anyone who tries to understand the patch.
Object boxes may have many different classes. The class is usually determined by the selector of the creation message, i.e., the first atom of the creation message which is usually a symbol.
Each class comes with a fixed collection of messages it may be sent. For example, the "float" or "f" object takes "bang" and "float." These messages are sent to "float" objects (objects whose class is float) via the leftmost, hot inlet. (The right inlet is a separate, auxiliary object.) Objects of class "float" respond to the message "bang" by outputting their current value, that is, by sending a "float" message to their outlet. They respond to "float" messages by setting their value and then outputting it.
Each other class (like "float") in Pd has its own protocol for responding to messages it is sent, and may take "float" and "bang" messages, or others in addition or instead of them.
Unless they arrange otherwise by defining a "list" method, objects respond to the "list" message by distributing the arguments of the message to their inlets, except for the first argument which is passed as a "float" or "symbol" message to the object proper.
Object boxes contain text which forms a message to be sent to Pd to create and initialize the object. Here, $1, etc., are taken from the context in which the patch was loaded. When the patch is a new document or opened from a file the "$" variables are undefined. But if the patch is an abstraction (see the next section) they are taken from the abstractions' creation arguments.
Constructions such as "$1-x" are expanded by string concatenation. This is the mechanism for making local variables. In particular, $0 in an abstraction is a counter which is guaranteed to be unique to that abstraction, so sends and receives with names like "$0-bear" can be used as local send/receive pairs.
Note that the expansion of variables such as $0 and $1 only works at the beginning of the symbol; so, for instance, "rats-$1" will not be expanded. Occasionally you may want to have double or triple substitutions; this can be done one stage at a time by nesting abstractions (with each subpatch adding its own $-variable to the beginning of a symbol and passing that on as argument to a further abstraction.)
For example, if you want to get dog-food, dog-ears, and cat-food, for example, have an abstraction "a1" that invokes an abstraction "a2" twice, as "a2 $1-food" and "a2 $1-ears", and then in a third patch call a1 twice, as "a1 cat" and "a1 dog". Inside the four "a2" copioes, $1 will evaluate to "dog-food", "cat-food", "dog-ears", and "cat-ears".
The contents of the subpatch are saved as part of the parent patch, in one file. If you make several copies of a subpatch you may change them individually.
The objects, "inlet,", "inlet~," "outlet," and "outlet~,", when put in a subpatch, create inlets and outlets for the object box containing the subpatch. This works equally for one-off subpatches and abstractions. The inlet~ and outlet~ versions create inlets and outlets for audio signals. You can't mix messages and audio in a subpatch inlet or outlet; they must be one or the other exclusively. Inlets and outlets appear on the invoking box in the same left-to-right order as they appear in the subpatch.
To make an abstraction, save a patch with a name such as "abstraction1.pd" and then invoke it as "abstraction1" in an object box:
Here we're invoking a separate file, "abstraction1.pd", which holds the patch shown here (the border is the same as for the subpatch above):
Abstractions are instantiated by typing the name of a patch (minus the ".pd" extension) into an object box. You may also type arguments; for instance if you have a file "my-abstraction.pd" you may type "my-abstraction 5" to set the variable $1 to 5. This is defined only for object boxes (not for messages) in the abstraction. (For message boxes, "$1", etc, have a different meaning as described above.) If you want to send a message with a $1 in the sense of a creation argument of an abstraction, you must generate it with an object box such as "float $1", "symbol $1", or perhaps "pack $1 $2", which may then be sent to a message box.
The corresponding feature in Max (both Opcode and Ircam) was the "#1" construct. In a Max abstraction, "#1", etc., are replaced by the creation argument. This has the disadvantage that you can't edit the abstraction as instantiated in the patch since the "#" variables are substituted. In Pd the "$" variables in object boxes are spelled literally as "$" variables so that it's meaningful to edit them from within their calling patch. On the Pd side, however, there is the disadvantage that it's confusing to have "$" expanded at a different time in an object box than in a message box. In an object box, the "$" argument is expanded at creation time, and in a message box, at message time.
To open the subpatch, right click on the object and select "open". (On Macintoshes without a 2-button mouse, you can double-click in edit mode instead.) It doesn't work just to click on the object in run mode since clicks are sent to visible controls and/or arrays.
When the sub-patch is closed, all controls in it appear on the object instead; so the number box in the sub-patch in the example above is the same one as you see in the box. Only controls are made visible in this way
Arrays in Pd should be allocated (and possible read in from a file) before beginning to make sound, since memory allocation and disk operations may take long enough to cause audio buffer overruns or underruns. Pd provides two ways to define new arrays, as "graphs" and "tables". In either case the array has a pre-defined name and size (i.e., number of points). Elements of the array are stored as floating-point numbers, 4 bytes apiece
If you use an array to store a one-second sound at 44.1 kHz you will need 176 kilobytes, or a one-minute sound, 10.6 megabytes. To store a sound with two or more channels, use a separate array for each channel.
Arrays are also useful as transfer functions, for example for nonlinear distortion of an audio signal, or to map a control onto a synthesis parameter. In situations like this one typically uses much shorter arrays, of no more than a few hundred elements. They are also useful for storing measured spectra derived from the fft~ objects, and probably for many other uses.
Arrays usually appear within subpatches created to house them, whether in "graph on parent" form (so that you see them within a rectangle drawn on the containing patch), or as a regular subpatch (which you see as a text box.) In the "graph on parent" form, an array appears as shown:
Arrays are indexed from 0 to N-1 where N is the number of points in the array. You can read an array value using the tabread object:
The two previous examples showed control operations to read and write from and to arrays. These may also be done using audio signals. For example, the patch below creates a 440 Hz. tone with "array1" as a waveform:
To create a new array, select "array" from the "put" menu. Up will come a dialog window to set initial properties of the array. By default, a new graph is created to hold the array, but it may also be housed in the most recently created graph instead. Other properties may be specified there and/or changed later using the "properties" dialog.
If you select "properties" on an array in a graph, you two dialogs, one for the array and one for the graph. The array dialog looks like this:
If you check "delete me" and then "OK", the array will be deleted. This is an odd interface for deleting an object, and is only provided because Pd lacks a mechanism for selecting arrays (so that "cut" could serve).
The graph dialog (which also pops up) is shown here:
The X bounds initially range from 0 to the number of points in the table minus one (this is a good choice for arrays, although graphs holding other kinds of objects might require other X bounds.) The Y bounds should be chosen to reflect the natural range of the table, so that stored sounds would naturally range from -1 to 1, but a sequence of frequency values might range from 0 to 20,000. Finally, you choose the screen size of the graph, width and height, in screen pixels.
Many other operations are defined for arrays; see the related patches in the tutorial (starting at 2.control/15.array.pd) for more possibilities.
The original idea in developing Pd was to make a real-time computer music performance environment like Max, but somehow to include also a facility for making computer music scores with user-specifiable graphical representations. This idea has important precedents in Eric Lindemann's Animal and Bill Buxton's SSSP. An even earlier class of precedents lies in the rich variety of paper scores for electronic music before it became practical to offer a computer-based score editor. In this context, scores by Stockhausen ( Kontakte and Studie II) and Yuasa (Toward the Midnight Sun) come most prominently to mind, but also Xenakis's Mycenae-alpha, which, although it was realized using a computer, was scored on paper and only afterward laboriously transcribed into the computer.
Pd is designed to to offer an extremely unstructured environment for describing data structures and their graphical appearance. The underlying idea is to allow the user to display any kind of data he or she wants to, associating it in any way with the display. To accomplish this Pd introduces a graphical data structure, somewhat like a data structure out of the C programming language, but with a facility for attaching shapes and colors to the data, so that the user can visualize and/or edit it. The data itself can be edited from scratch or can be imported from files, generated algorithmically, or derived from analyses of incoming sounds or other data streams. Here is one simple example of a very short musical sketch realized using Pd:
Each object is thus composed of a combination of scalar values (color; aggregate position in X and Y coordinates) and array values (time/value pairs for the black traces and time/frequency/bandwidth triples for the colored ones.) This is all specified by the user using Pd's "template" mechanism.
Here is the template associated with the graphical objects shown above:
In general, data structures are built from four data types: scalar floats and symbols, arrays (whose elements share another, specified template) and lists (whose elements may have a variety of templates). The contents of a Pd window themselves form a list. Pd's correlate of Max's "table" object is implemented as a top-level array whose elements are scalars containing a single floating-point number.
Data structures in Pd may nest arbitrarily deeply using the array and list types. For example, a collection of sinusoidal tracks from an analysis engine could be implemented as an array of arrays of (pitch, amplitude) pairs; this appears as example 12 in Pd's FFT object online tutorial.
After the "struct" object in the template shown above, the remaining three objects are drawing instructions , first for a rectangle ("filledpolygon"), and then for two arrays. The various graphical attributes that are specified for drawing instructions may be numerical constants or data structure field names; in the latter case the value varies depending on the data. For instance, the second creation argument to "plot" is the color. The first "plot" plots the "amp" field and the color is given as 0, or black. The second one plots "pitch" using the color "voiceno". In this way the color of the second trace is attached to the "voiceno" slot in the data structure, so that color will vary according to its "voiceno" slot.
Pd objects are provided to traverse lists and arrays, and to address elements of data structures for getting and setting. Here is a patch showing how these facilities could be used, for example, to sequence the graphical score shown above:
Pd has no built-in sequencer, nor even any notion that "x" values should be used as a time axis. (However, a "sort" function is provided, which reorders a list from left to right, on the assumption that users might often want to use Pd data collections as x-ordered sequences.) Recording sequences of events into lists, and/or playing the lists back as sequences, are functionalities that the user is expected to supply on top of Pd's offerings, which, it is hoped, would allow those functionalities within a much larger range of possibilities, to include random re-orderings of events, score following, self-modifying scores, reactive improvisation, and perhaps much more.
Traversal of data is made possible by adding a new type of atom, "pointer", to the two previously defined types that make up messages, to wit, numbers and symbols. Unlike numbers and symbols, pointers have no printed form and thus can't be uttered in message boxes. Traversal objects such as "pointer" and "get" (among several others) can generate or use pointers. The pointer data type is also integrated into pipe-fitting objects such as "pack", "unpack", and "route".
In the patch shown above, the topmost "pointer" object holds a pointer to the next object to "play" (by sending it to one of the "voice" abstractions at bottom.) The pointer object takes a "traverse" message to set it to the head of the list (named "pd-data"), and "next" messages to move to (and output) the next datum in the list (i.e., the next in the list of six objects in the score). Another "pointer" object is also used, further down, as a storage cell for pointers just as "float" is for numbers.
The center of any sequencer is always the "delay" object, which must be fed the time difference between each event (including the non-event of hitting "start") and the next. As we extract each of the six objects in the score, we must wait the delay for playing that object, and then send its pointer to one of the "voice" abstractions to play it. However, we have to inspect the object itself to know the delay before playing it. So, in the loop, we peel off the first remaining object to play and inspect the time difference between it and the previous one, using this value to set the delay, but also storing the pointer in the lower "pointer" and "pack" objects.
The time difference needed to set the delay object is obtained using the "get template-toplevel x" object. (This is converted to incremental time ("-"), corrected for tempo, and fed to the delay.) Pd provides the "get" and "set" objects for reading and writing values from data structures. The two "get" objects shown here obtain the "x" and "voiceno" fields of the current object. The template name (template-toplevel) is supplied to the "get" objects so that they can look up the offset of the necessary field(s) in advance, for greater run-time efficiency.
Once the delay has expired, the object's pointer is recalled (the lower "pointer" object), and the voice number is recalled. This is packed with the pointer itself and routed, so that the pointer goes to the appropriate voice. The voice number is shown as the color of the frequency trace in "999" units (first digit red, second green, third blue) and the "route" is arbitrarily set up to select among the six primary and secondary colors plus black.
The details of extracting the pitch and dynamic breakpoints from the arrays defined in the template are managed in the "voice" abstraction. The "voice" abstraction receives a pointer to a given object and manages the sequencing of the arrays; so it contains two sequencers itself. The nesting of the overall structure of the sequencer patch mirrors the nesting of the original data structures. Finally, the voice abstraction puts its audio output on a summing bus.
More general patches can easily be constructed which access heterogeneous lists of objects (having different templates). In this way, an arbitrarily rich personal "score language" can be developed and sequenced.
In general, accessing or changing data is done via "pointers" to "scalars". Numbers and symbols within scalars are accessed using the "get" object and changed, in the same way, using "set". Since lists and arrays are composed of scalars, every actual number or symbol in a data heap will be a number or symbol element of some scalar. To access them, it suffices to have objects to chase down elements of lists and arrays (given either a global name or a pointer to the containing scalar).
Lists are traversed in the way shown above; to get to a sublist of a scalar, the "get" object will provide a pointer, in the same way as it provides "float" or "symbol" elements of scalars. For arrays, an "element" object is provided which, given a scalar, a field name and a number, chases down the numbered, scalar, element of the named array field.
To alter "float" or "symbol" elements of scalars is straightforward using the "set" object, but arrays and lists can't be set by assignment; there is no suitable data type available within messages. Lists could possibly be "settable" by passing pointers to other lists, but permitting this would have required either automatically doing deep copies of data structures to carry out the assignments, or else implementing a garbage collecting memory management system, either of which would be difficult to realize within real-time computation time constraints. Instead, all the data hanging from a scalar is considered as belonging to that scalar, and is left in memory until the scalar is deleted; the data may be changed atom by atom, but primitives are not provided which would imply unpredictable execution times.
The "getsize" and "setsize" objects are provided to access or change the number of elements in the array. For lists, an "append" object appends a new scalar for a given template to a list, after the element pointed to. (To insert a scalar at the beginning of a list, the pointer can be set to the "head" of the list, a formal location before the first list item.) Deletion is less flexible; the only operation is to delete an entire list. (There's no reason not to provide finer-grain deletion mechanisms except that it's not clear how to protect against stale pointers efficiently, except by voiding the entire collection of pointers into a list.)
The graphical score shown above can be edited by dragging breakpoints, or by adding and deleting them, using mouse clicks. Also, entire objects or collections of them may be copied, pasted, and dragged around the screen. Alternatively, there is an editable (or computer generate-able or parse-able) text representation for the data, which may be seen or changed in a dialog window or read and written to external text files.
Since the graphical presentation of data objects is determined by drawing instructions, the drawing instructions are interpreted backwards to alter data as a result of mouse operations. If a given graphical dimension is controlled by a variable, that variable is then controlled by dragging along that dimension; if the dimension is constant, it can't be altered by dragging.
Tricky situations can arise when the user changes the contents of templates. A change in drawing instructions can be accommodated by simply tracking down and redrawing all data objects using the template. However, changing the "struct" object itself make for less straightforward situations. The user might wish to reorder fields, delete them, add new ones, or rename them. When a "struct" object changes, Pd automatically conforms the data from the old structure to the new one. Fields with the same name as previously are maintained (reordering them as necessary); and if a field disappears but another of the same type appears, the new one(s) are taken to be renamings of the old one(s) in order of appearance. New fields which cannot be matched in this way with previously existing ones are assumed to be new and are initialized.
It can happen that two "struct" objects compete to define the same data structure, or that the user reads in data from a file which expects a different version of the structure, or alternatively, that the "struct" object for existing data objects disappears. For this reason, Pd maintains a private representation of the last active version of a "struct" until all similarly named "structs," as well as all data using that "struct", have disappeared. If the user introduces a new version of the "struct" and only later deletes the "current" one, the data is only conformed to the new version once the old one is deleted. In this way we avoid getting into situations where data is left hanging without its structure definition, or where data ends up belonging to two or more structures of the same name. The worst that can happen is that data may lose their drawing instructions, in which case Pd supplies a simple default shape.
When examples get more complicated and/or dense than the one shown here, it becomes difficult to see and select specific features of a data collection; more work is needed to facilitate this. There should be some facility for turning drawing instructions on and off, or perhaps for switching between versions of a template, depending on the user's desired view. There should also be a callback facility in the template for when an object is edited with the mouse, so that the user can bind actions to mouse clicks.
More generally, the collection of traversal objects that Pd provides is adequate to support a variety of modes of data collection and use, such as analysis and sequencing. But the patches required to traverse the data collections are not always simple. It would be desirable to find a more straightforward mechanism than that provided by the "pointer", "get" and "set" objects.
The "data" facility, although part of the original plan for Pd, has only recently been implemented in its current form, and as (hopefully) the user base grows there will surely be occasions for many further extensions of the data handling primitives and the graphical presentation and editing functions.


I will buy you all
The chocolate that you want
Now below half price
The most budget
Day ever, 2017
Next


Why is Tom Selleck the Best of All Time?
He is, and Always will be the Thomas Magnum
-
Hawaiian Shirts
-
Mustache
-
Drives Ferarri, but never has any money
-
Has Endless Tab at Hawaii Club
Even when watching some of Tom Sellecks films, such as Mr. Beisbol, you still think of him as Magnum
Friends
Argueable the best 9 Episodes of the 10 season TV show Friends, are those where Tom Selleck Appears
"We named the dog indiana!"
Probably the one Greatest thing of all is that Tom Selleck TURNED DOWN an offer to play Indiana Jones, due to the fact he was "busy" filming Magnum P.I.


Reading Corner
Newspapers - Editorials
The Hindu - Opinions
The Guardian - Opinions
The Econimic Times - Blogs
The New York Times - Opinions
The Wall Street Journal - Opinions
BBC
The Indian Express - Opinions
The Washington Post - Opinions
China Daily - Opinions
The Sydney Morning Herald - Editorials
The Christian Science Monitor - Commentary
The Asahi Shimbun - Opinions
The DAWN - Opinions
The Vancouver Sun - Opinions
Magazines
The Economist
1843
The Week
India Today
Forbes
Fortune
Technology Blogs & Magazines
Hacker News
Dev.to
Digit
The Wired
MIT Technology Review
Fast Company
Innovation and Tech Today, STEM
Engineering & Technology(E&T)
Gartner Research & Advisory
Blogs & Articles
AEON - big ideas, serious enquiry and a humane worldview
PSYCHE - elucidating the human condition through three prisms: mental health; the perennial question of ‘how to live’; and the artistic and transcendent facets of life.
Arts and Letters Daily
Smithsonian Magazines
Scientific American
American Scientist
Bill Gates Blogs
Raghuram Rajan Blogs
International Organisations
IMF
WEF
WEF - Strategic Intelligence
UN
UNICEF
WHO
Government of India
NITI Aayog
Press Information Bureau
Indian Metrological Department
Startup India
MeitY
Registration Application Forms
CAT & OMET
CAT Registration Website
IIM-A
IIM-B
IIM-C
OMET - XAT - XLRI
CAT Trainers
GPKAFUNDA - CL Team
Career Launcher
Time
Byjus
GMAT
ISB
LBS
Cambridge - Judge
Wharton
NUS
NTU
INSEED
HEC PARIS
OXFORD SAID


Biz[Rez] Tech Insight
Home
Social
Twitter
GitHub
Delicious
LinkedIn
Coderwall
RSS
Projects
Earth.js
Parting Out the Civic
Posts Tagged “disqus”
How I built my blog in one day
March 8, 2012
. Coding .
A tutorial on how I built my blog
jekyll
bootstrap
github
disqus


| Home | Libraries | People | FAQ | More |
Copyright © 2007 Paul A. Bristow, Hubert Holin, John Maddock, Daryle Walker and Xiaogang Zhang
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
The following libraries are present in Boost.Math:
|
Library |
Description |
|---|---|
|
Complex Number Inverse Trigonometric Functions |
These complex number algorithms are the inverses of trigonometric functions currently present in the C++ standard. Equivalents to these functions are part of the C99 standard, and are part of the Technical Report on C++ Library Extensions. |
|
Greatest Common Divisor and Least Common Multiple |
The class and function templates in <boost/math/common_factor.hpp> provide run-time and compile-time evaluation of the greatest common divisor (GCD) or least common multiple (LCM) of two integers. These facilities are useful for many numeric-oriented generic programming problems. |
|
Octonions |
Octonions, like quaternions, are a relative of complex numbers. Octonions see some use in theoretical physics.
In practical terms, an octonion is simply an octuple of real numbers
(α,β,γ,δ,ε,ζ,η,θ), which we can write in the form
Addition and a multiplication is defined on the set of octonions, which
generalize their quaternionic counterparts. The main novelty this time
is that the multiplication is not only not commutative,
is now not even associative (i.e. there are quaternions
Octonions (and their kin) are described in far more details in this other document (with errata and addenda). Some traditional constructs, such as the exponential, carry over without too much change into the realms of octonions, but other, such as taking a square root, do not (the fact that the exponential has a closed form is a result of the author, but the fact that the exponential exists at all for octonions is known since quite a long time ago). |
|
Special Functions |
Provides a number of high quality special functions, initially these were concentrated on functions used in statistical applications along with those in the Technical Report on C++ Library Extensions. The function families currently implemented are the gamma, beta & erf functions along with the incomplete gamma and beta functions (four variants of each) and all the possible inverses of these, plus digamma, various factorial functions, Bessel functions, elliptic integrals, sinus cardinals (along with their hyperbolic variants), inverse hyperbolic functions, Legrendre/Laguerre/Hermite polynomials and various special power and logarithmic functions. All the implementations are fully generic and support the use of arbitrary "real-number" types, although they are optimised for use with types with known-about significand (or mantissa) sizes: typically float, double or long double. |
|
Statistical Distributions |
Provides a reasonably comprehensive set of statistical distributions, upon which higher level statistical tests can be built. The initial focus is on the central univariate distributions. Both continuous (like normal & Fisher) and discrete (like binomial & Poisson) distributions are provided. A comprehensive tutorial is provided, along with a series of worked examples illustrating how the library is used to conduct statistical tests. |
|
Quaternions |
Quaternions are a relative of complex numbers.
Quaternions are in fact part of a small hierarchy of structures built
upon the real numbers, which comprise only the set of real numbers (traditionally
named R), the set
of complex numbers (traditionally named C),
the set of quaternions (traditionally named H)
and the set of octonions (traditionally named O),
which possess interesting mathematical properties (chief among which
is the fact that they are division algebras, i.e.
where the following property is true: if One of the most important aspects of quaternions is that they provide an efficient way to parameterize rotations in R3 (the usual three-dimensional space) and R4.
In practical terms, a quaternion is simply a quadruple of real numbers
(α,β,γ,δ), which we can write in the form
An addition and a multiplication is defined on the set of quaternions,
which generalize their real and complex counterparts. The main novelty
here is that the multiplication is not commutative
(i.e. there are quaternions Quaternions (and their kin) are described in far more details in this other document (with errata and addenda). Some traditional constructs, such as the exponential, carry over without too much change into the realms of quaternions, but other, such as taking a square root, do not. |
The following Boost libraries are also mathematically oriented:
|
Library |
Description |
|---|---|
|
Headers to ease dealing with integral types. |
|
|
As implied by its name, this library is intended to help manipulating mathematical intervals. It consists of a single header <boost/numeric/interval.hpp> and principally a type which can be used as interval<T>. |
|
|
Boost.MultiArray provides a generic N-dimensional array concept definition and common implementations of that interface. |
|
|
The Boost Numeric Conversion library is a collection of tools to describe and perform conversions between values of different numeric types. |
|
|
The header <boost/operators.hpp> supplies several sets of class templates (in namespace boost). These templates define operators at namespace scope in terms of a minimal number of fundamental operators provided by the class. |
|
|
Random numbers are useful in a variety of applications. The Boost Random Number Library (Boost.Random for short) provides a vast variety of generators and distributions to produce random numbers having useful properties, such as uniform distribution. |
|
|
The header rational.hpp provides an implementation of rational numbers. The implementation is template-based, in a similar manner to the standard complex number class. |
|
|
uBLAS is a C++ template class library that provides BLAS level 1, 2, 3 functionality for dense, packed and sparse matrices. The design and implementation unify mathematical notation via operator overloading and efficient code generation via expression templates. |
Last revised: May 28, 2008 at 10:39:25 +0100 |


Virtual Tour
Department of Information Technology
Dept. of Information Technology Block - Front Elevation
Information Technology Programming Lab
Please enable Javascript!
Please click the below options to view our 360 Degree Virtual Reality Tours
Dept. of Information
Technology Block
- Front Elevation
Information Technology
Programming Lab
Flash
|
Quicktime
Flash
|
Quicktime
Copyright © All Rights Reserved.
Madras Institute of Technology - Department of Information Technology
Powered by www.zeal360.com [A Division of Infosams Technology & Media Limited]
Your browser does not support the audio tag.


When you work with us, you are part of a team of committed collaborators. All aspects of our software development process are intergrated and agile.
Our approach unifies design, development and product management to create exceptional products.
We starts each project by understanding your business goals, the user's needs and the product requiremnts
Then we help translate them into effective and elegant solutions.
Before we sign a contrac or write a line of code, our team will spend the necessary time needed to understand your product vison
The outcome of this scoping sessiom is a proposal or high-level statement of work
Based on your requirements, we can provide a complete offering or just the pieces you need.


I am from Long Island, New York. I graduated with my Bachelor's in Science in
Computer Programming & Information Systems on May 2018. I am excited with the
opportunity to work with one of the world's best technology and e-commerce company.
Until then, to coding and beyond!
Skills:
Fun Facts.. about me:
Top 5 Favorite Shows:


The Myer-Briggs Type Indicator is a quiz of sorts which by asking questions can draw to a conclusion on your personality type and "psychological preferences" in how you and others view not only the world but also how you make decisions.
This test is a great way to gain an understanding of different but general personality types. It breaks each personality down across the following factors: Introversion/Extroversion, Intuition/Sensing, Feeling/Thinking and Judging/Perceiving. Depending on the answers provided, people are categorized into these four categories which best align with their traits.
These types include the following:
"Perception involves all the ways of becoming aware of things, people, happenings, or ideas. Judgment involves all the ways of coming to conclusions about what has been perceived. If people differ systematically in what they perceive and in how they reach conclusions, then it is only reasonable for them to differ correspondingly in their interests, reactions, values, motivations, and skills."


Sting operation busts ‘fraudulent’ licensing officials
Police say they arrested a driving school operator and two examiners – a man and a woman – on Friday.
by News24WireImage: iStock
Five people – including vehicle testing examiners, licensing officials and a driving school operator – have been arrested in Limpopo for fraudulently issuing drivers licenses.
Three arrests came after a sting operation, involving the Hawks, at the Sibasa driver licence testing centre in Thohoyandou, confirmed Road Traffic Management Corporation (RTMC) spokesperson Simon Zwane.
Officers of the RTMC’s national traffic anti-corruption unit received a tip-off indicating that drivers licenses were being fraudulently issued to applicants for a fee. The officers enlisted the help of the Limpopo division of the Hawks to stage a sting operation at the testing centre, which saw them arresting a driving school operator and two examiners – a man and a woman – on Friday.
During the operation, officers also seized relevant documents. The suspects have been detained at Thohoyandou police station and are expected to appear in court next week.
In another operation on Friday, three vehicle testing examiners were arrested for a second time, in Marble Hall, for fraudulently issuing vehicle roadworthy certificates for vehicles that they had never tested.
The arrests took place at a private vehicle testing station, which was previously raided by the anti-corruption unit and the Hawks. The suspects were on bail following an arrest for similar allegations last month.
“Another two suspects are being sought in connection with these allegations,” Zwane says.
Around 30 vehicle examiners were arrested in Limpopo last month on charges of fraud relating to the issuing of vehicle road-worthiness certificates.
“Corruption and fraud are a major influence in the high number of road fatalities in the country and the RTMC has prioritised this crime in efforts to make South African roads safe. Members of the public to assist by reporting suspected bribery, fraud and corruption on 0861 400 800 or by emailing ntacu@rtmc.co.za,” Zwane adds.


*
*
*
SAVE
PREVIOUS
NEXT
Candidate's image
Candidate's Signature
Candidate's 12th Admit card
Candidate's OBC


Routing
- Basic Routing
- Route Parameters
- Named Routes
- Route Groups
- Route Model Binding
- Fallback Routes
- Rate Limiting
- Form Method Spoofing
- Accessing The Current Route
- Cross-Origin Resource Sharing (CORS)
- Route Caching
Basic Routing
The most basic Laravel routes accept a URI and a closure, providing a very simple and expressive method of defining routes and behavior without complicated routing configuration files:
use Illuminate\Support\Facades\Route;
Route::get('/greeting', function () {
return 'Hello World';
});
The Default Route Files
All Laravel routes are defined in your route files, which are located in the routes
directory. These files are automatically loaded by your application's App\Providers\RouteServiceProvider
. The routes/web.php
file defines routes that are for your web interface. These routes are assigned the web
middleware group, which provides features like session state and CSRF protection. The routes in routes/api.php
are stateless and are assigned the api
middleware group.
For most applications, you will begin by defining routes in your routes/web.php
file. The routes defined in routes/web.php
may be accessed by entering the defined route's URL in your browser. For example, you may access the following route by navigating to http://example.com/user
in your browser:
use App\Http\Controllers\UserController;
Route::get('/user', [UserController::class, 'index']);
Routes defined in the routes/api.php
file are nested within a route group by the RouteServiceProvider
. Within this group, the /api
URI prefix is automatically applied so you do not need to manually apply it to every route in the file. You may modify the prefix and other route group options by modifying your RouteServiceProvider
class.
Available Router Methods
The router allows you to register routes that respond to any HTTP verb:
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);
Sometimes you may need to register a route that responds to multiple HTTP verbs. You may do so using the match
method. Or, you may even register a route that responds to all HTTP verbs using the any
method:
Route::match(['get', 'post'], '/', function () {
//
});
Route::any('/', function () {
//
});
Dependency Injection
You may type-hint any dependencies required by your route in your route's callback signature. The declared dependencies will automatically be resolved and injected into the callback by the Laravel service container. For example, you may type-hint the Illuminate\Http\Request
class to have the current HTTP request automatically injected into your route callback:
use Illuminate\Http\Request;
Route::get('/users', function (Request $request) {
// ...
});
CSRF Protection
Remember, any HTML forms pointing to POST
, PUT
, PATCH
, or DELETE
routes that are defined in the web
routes file should include a CSRF token field. Otherwise, the request will be rejected. You can read more about CSRF protection in the CSRF documentation:
<form method="POST" action="/profile">
@csrf
...
</form>
Redirect Routes
If you are defining a route that redirects to another URI, you may use the Route::redirect
method. This method provides a convenient shortcut so that you do not have to define a full route or controller for performing a simple redirect:
Route::redirect('/here', '/there');
By default, Route::redirect
returns a 302
status code. You may customize the status code using the optional third parameter:
Route::redirect('/here', '/there', 301);
Or, you may use the Route::permanentRedirect
method to return a 301
status code:
Route::permanentRedirect('/here', '/there');
{note} When using route parameters in redirect routes, the following parameters are reserved by Laravel and cannot be used:
destination
andstatus
.
View Routes
If your route only needs to return a view, you may use the Route::view
method. Like the redirect
method, this method provides a simple shortcut so that you do not have to define a full route or controller. The view
method accepts a URI as its first argument and a view name as its second argument. In addition, you may provide an array of data to pass to the view as an optional third argument:
Route::view('/welcome', 'welcome');
Route::view('/welcome', 'welcome', ['name' => 'Taylor']);
{note} When using route parameters in view routes, the following parameters are reserved by Laravel and cannot be used:
view
,data
,status
, andheaders
.
Route Parameters
Required Parameters
Sometimes you will need to capture segments of the URI within your route. For example, you may need to capture a user's ID from the URL. You may do so by defining route parameters:
Route::get('/user/{id}', function ($id) {
return 'User '.$id;
});
You may define as many route parameters as required by your route:
Route::get('/posts/{post}/comments/{comment}', function ($postId, $commentId) {
//
});
Route parameters are always encased within {}
braces and should consist of alphabetic characters. Underscores (_
) are also acceptable within route parameter names. Route parameters are injected into route callbacks / controllers based on their order - the names of the route callback / controller arguments do not matter.
Parameters & Dependency Injection
If your route has dependencies that you would like the Laravel service container to automatically inject into your route's callback, you should list your route parameters after your dependencies:
use Illuminate\Http\Request;
Route::get('/user/{id}', function (Request $request, $id) {
return 'User '.$id;
});
Optional Parameters
Occasionally you may need to specify a route parameter that may not always be present in the URI. You may do so by placing a ?
mark after the parameter name. Make sure to give the route's corresponding variable a default value:
Route::get('/user/{name?}', function ($name = null) {
return $name;
});
Route::get('/user/{name?}', function ($name = 'John') {
return $name;
});
Regular Expression Constraints
You may constrain the format of your route parameters using the where
method on a route instance. The where
method accepts the name of the parameter and a regular expression defining how the parameter should be constrained:
Route::get('/user/{name}', function ($name) {
//
})->where('name', '[A-Za-z]+');
Route::get('/user/{id}', function ($id) {
//
})->where('id', '[0-9]+');
Route::get('/user/{id}/{name}', function ($id, $name) {
//
})->where(['id' => '[0-9]+', 'name' => '[a-z]+']);
For convenience, some commonly used regular expression patterns have helper methods that allow you to quickly add pattern constraints to your routes:
Route::get('/user/{id}/{name}', function ($id, $name) {
//
})->whereNumber('id')->whereAlpha('name');
Route::get('/user/{name}', function ($name) {
//
})->whereAlphaNumeric('name');
Route::get('/user/{id}', function ($id) {
//
})->whereUuid('id');
If the incoming request does not match the route pattern constraints, a 404 HTTP response will be returned.
Global Constraints
If you would like a route parameter to always be constrained by a given regular expression, you may use the pattern
method. You should define these patterns in the boot
method of your App\Providers\RouteServiceProvider
class:
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
Route::pattern('id', '[0-9]+');
}
Once the pattern has been defined, it is automatically applied to all routes using that parameter name:
Route::get('/user/{id}', function ($id) {
// Only executed if {id} is numeric...
});
Encoded Forward Slashes
The Laravel routing component allows all characters except /
to be present within route parameter values. You must explicitly allow /
to be part of your placeholder using a where
condition regular expression:
Route::get('/search/{search}', function ($search) {
return $search;
})->where('search', '.*');
{note} Encoded forward slashes are only supported within the last route segment.
Named Routes
Named routes allow the convenient generation of URLs or redirects for specific routes. You may specify a name for a route by chaining the name
method onto the route definition:
Route::get('/user/profile', function () {
//
})->name('profile');
You may also specify route names for controller actions:
Route::get(
'/user/profile',
[UserProfileController::class, 'show']
)->name('profile');
{note} Route names should always be unique.
Generating URLs To Named Routes
Once you have assigned a name to a given route, you may use the route's name when generating URLs or redirects via Laravel's route
and redirect
helper functions:
// Generating URLs...
$url = route('profile');
// Generating Redirects...
return redirect()->route('profile');
If the named route defines parameters, you may pass the parameters as the second argument to the route
function. The given parameters will automatically be inserted into the generated URL in their correct positions:
Route::get('/user/{id}/profile', function ($id) {
//
})->name('profile');
$url = route('profile', ['id' => 1]);
If you pass additional parameters in the array, those key / value pairs will automatically be added to the generated URL's query string:
Route::get('/user/{id}/profile', function ($id) {
//
})->name('profile');
$url = route('profile', ['id' => 1, 'photos' => 'yes']);
// /user/1/profile?photos=yes
{tip} Sometimes, you may wish to specify request-wide default values for URL parameters, such as the current locale. To accomplish this, you may use the
URL::defaults
method.
Inspecting The Current Route
If you would like to determine if the current request was routed to a given named route, you may use the named
method on a Route instance. For example, you may check the current route name from a route middleware:
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->route()->named('profile')) {
//
}
return $next($request);
}
Route Groups
Route groups allow you to share route attributes, such as middleware, across a large number of routes without needing to define those attributes on each individual route.
Nested groups attempt to intelligently "merge" attributes with their parent group. Middleware and where
conditions are merged while names and prefixes are appended. Namespace delimiters and slashes in URI prefixes are automatically added where appropriate.
Middleware
To assign middleware to all routes within a group, you may use the middleware
method before defining the group. Middleware are executed in the order they are listed in the array:
Route::middleware(['first', 'second'])->group(function () {
Route::get('/', function () {
// Uses first & second middleware...
});
Route::get('/user/profile', function () {
// Uses first & second middleware...
});
});
Subdomain Routing
Route groups may also be used to handle subdomain routing. Subdomains may be assigned route parameters just like route URIs, allowing you to capture a portion of the subdomain for usage in your route or controller. The subdomain may be specified by calling the domain
method before defining the group:
Route::domain('{account}.example.com')->group(function () {
Route::get('user/{id}', function ($account, $id) {
//
});
});
{note} In order to ensure your subdomain routes are reachable, you should register subdomain routes before registering root domain routes. This will prevent root domain routes from overwriting subdomain routes which have the same URI path.
Route Prefixes
The prefix
method may be used to prefix each route in the group with a given URI. For example, you may want to prefix all route URIs within the group with admin
:
Route::prefix('admin')->group(function () {
Route::get('/users', function () {
// Matches The "/admin/users" URL
});
});
Route Name Prefixes
The name
method may be used to prefix each route name in the group with a given string. For example, you may want to prefix all of the grouped route's names with admin
. The given string is prefixed to the route name exactly as it is specified, so we will be sure to provide the trailing .
character in the prefix:
Route::name('admin.')->group(function () {
Route::get('/users', function () {
// Route assigned name "admin.users"...
})->name('users');
});
Route Model Binding
When injecting a model ID to a route or controller action, you will often query the database to retrieve the model that corresponds to that ID. Laravel route model binding provides a convenient way to automatically inject the model instances directly into your routes. For example, instead of injecting a user's ID, you can inject the entire User
model instance that matches the given ID.
Implicit Binding
Laravel automatically resolves Eloquent models defined in routes or controller actions whose type-hinted variable names match a route segment name. For example:
use App\Models\User;
Route::get('/users/{user}', function (User $user) {
return $user->email;
});
Since the $user
variable is type-hinted as the App\Models\User
Eloquent model and the variable name matches the {user}
URI segment, Laravel will automatically inject the model instance that has an ID matching the corresponding value from the request URI. If a matching model instance is not found in the database, a 404 HTTP response will automatically be generated.
Of course, implicit binding is also possible when using controller methods. Again, note the {user}
URI segment matches the $user
variable in the controller which contains an App\Models\User
type-hint:
use App\Http\Controllers\UserController;
use App\Models\User;
// Route definition...
Route::get('/users/{user}', [UserController::class, 'show']);
// Controller method definition...
public function show(User $user)
{
return view('user.profile', ['user' => $user]);
}
Customizing The Key
Sometimes you may wish to resolve Eloquent models using a column other than id
. To do so, you may specify the column in the route parameter definition:
use App\Models\Post;
Route::get('/posts/{post:slug}', function (Post $post) {
return $post;
});
If you would like model binding to always use a database column other than id
when retrieving a given model class, you may override the getRouteKeyName
method on the Eloquent model:
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'slug';
}
Custom Keys & Scoping
When implicitly binding multiple Eloquent models in a single route definition, you may wish to scope the second Eloquent model such that it must be a child of the previous Eloquent model. For example, consider this route definition that retrieves a blog post by slug for a specific user:
use App\Models\Post;
use App\Models\User;
Route::get('/users/{user}/posts/{post:slug}', function (User $user, Post $post) {
return $post;
});
When using a custom keyed implicit binding as a nested route parameter, Laravel will automatically scope the query to retrieve the nested model by its parent using conventions to guess the relationship name on the parent. In this case, it will be assumed that the User
model has a relationship named posts
(the plural form of the route parameter name) which can be used to retrieve the Post
model.
Customizing Missing Model Behavior
Typically, a 404 HTTP response will be generated if an implicitly bound model is not found. However, you may customize this behavior by calling the missing
method when defining your route. The missing
method accepts a closure that will be invoked if an implicitly bound model can not be found:
use App\Http\Controllers\LocationsController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;
Route::get('/locations/{location:slug}', [LocationsController::class, 'show'])
->name('locations.view')
->missing(function (Request $request) {
return Redirect::route('locations.index');
});
Explicit Binding
You are not required to use Laravel's implicit, convention based model resolution in order to use model binding. You can also explicitly define how route parameters correspond to models. To register an explicit binding, use the router's model
method to specify the class for a given parameter. You should define your explicit model bindings at the beginning of the boot
method of your RouteServiceProvider
class:
use App\Models\User;
use Illuminate\Support\Facades\Route;
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
Route::model('user', User::class);
// ...
}
Next, define a route that contains a {user}
parameter:
use App\Models\User;
Route::get('/users/{user}', function (User $user) {
//
});
Since we have bound all {user}
parameters to the App\Models\User
model, an instance of that class will be injected into the route. So, for example, a request to users/1
will inject the User
instance from the database which has an ID of 1
.
If a matching model instance is not found in the database, a 404 HTTP response will be automatically generated.
Customizing The Resolution Logic
If you wish to define your own model binding resolution logic, you may use the Route::bind
method. The closure you pass to the bind
method will receive the value of the URI segment and should return the instance of the class that should be injected into the route. Again, this customization should take place in the boot
method of your application's RouteServiceProvider
:
use App\Models\User;
use Illuminate\Support\Facades\Route;
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
Route::bind('user', function ($value) {
return User::where('name', $value)->firstOrFail();
});
// ...
}
Alternatively, you may override the resolveRouteBinding
method on your Eloquent model. This method will receive the value of the URI segment and should return the instance of the class that should be injected into the route:
/**
* Retrieve the model for a bound value.
*
* @param mixed $value
* @param string|null $field
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function resolveRouteBinding($value, $field = null)
{
return $this->where('name', $value)->firstOrFail();
}
If a route is utilizing implicit binding scoping, the resolveChildRouteBinding
method will be used to resolve the child binding of the parent model:
/**
* Retrieve the child model for a bound value.
*
* @param string $childType
* @param mixed $value
* @param string|null $field
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function resolveChildRouteBinding($childType, $value, $field)
{
return parent::resolveChildRouteBinding($childType, $value, $field);
}
Fallback Routes
Using the Route::fallback
method, you may define a route that will be executed when no other route matches the incoming request. Typically, unhandled requests will automatically render a "404" page via your application's exception handler. However, since you would typically define the fallback
route within your routes/web.php
file, all middleware in the web
middleware group will apply to the route. You are free to add additional middleware to this route as needed:
Route::fallback(function () {
//
});
{note} The fallback route should always be the last route registered by your application.
Rate Limiting
Defining Rate Limiters
Laravel includes powerful and customizable rate limiting services that you may utilize to restrict the amount of traffic for a given route or group of routes. To get started, you should define rate limiter configurations that meet your application's needs. Typically, this should be done within the configureRateLimiting
method of your application's App\Providers\RouteServiceProvider
class.
Rate limiters are defined using the RateLimiter
facade's for
method. The for
method accepts a rate limiter name and a closure that returns the limit configuration that should apply to routes that are assigned to the rate limiter. Limit configuration are instances of the Illuminate\Cache\RateLimiting\Limit
class. This class contains helpful "builder" methods so that you can quickly define your limit. The rate limiter name may be any string you wish:
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Support\Facades\RateLimiter;
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('global', function (Request $request) {
return Limit::perMinute(1000);
});
}
If the incoming request exceeds the specified rate limit, a response with a 429 HTTP status code will automatically be returned by Laravel. If you would like to define your own response that should be returned by a rate limit, you may use the response
method:
RateLimiter::for('global', function (Request $request) {
return Limit::perMinute(1000)->response(function () {
return response('Custom response...', 429);
});
});
Since rate limiter callbacks receive the incoming HTTP request instance, you may build the appropriate rate limit dynamically based on the incoming request or authenticated user:
RateLimiter::for('uploads', function (Request $request) {
return $request->user()->vipCustomer()
? Limit::none()
: Limit::perMinute(100);
});
Segmenting Rate Limits
Sometimes you may wish to segment rate limits by some arbitrary value. For example, you may wish to allow users to access a given route 100 times per minute per IP address. To accomplish this, you may use the by
method when building your rate limit:
RateLimiter::for('uploads', function (Request $request) {
return $request->user()->vipCustomer()
? Limit::none()
: Limit::perMinute(100)->by($request->ip());
});
To illustrate this feature using another example, we can limit access to the route to 100 times per minute per authenticated user ID or 10 times per minute per IP address for guests:
RateLimiter::for('uploads', function (Request $request) {
return $request->user()
? Limit::perMinute(100)->by($request->user()->id)
: Limit::perMinute(10)->by($request->ip());
});
Multiple Rate Limits
If needed, you may return an array of rate limits for a given rate limiter configuration. Each rate limit will be evaluated for the route based on the order they are placed within the array:
RateLimiter::for('login', function (Request $request) {
return [
Limit::perMinute(500),
Limit::perMinute(3)->by($request->input('email')),
];
});
Attaching Rate Limiters To Routes
Rate limiters may be attached to routes or route groups using the throttle
middleware. The throttle middleware accepts the name of the rate limiter you wish to assign to the route:
Route::middleware(['throttle:uploads'])->group(function () {
Route::post('/audio', function () {
//
});
Route::post('/video', function () {
//
});
});
Throttling With Redis
Typically, the throttle
middleware is mapped to the Illuminate\Routing\Middleware\ThrottleRequests
class. This mapping is defined in your application's HTTP kernel (App\Http\Kernel
). However, if you are using Redis as your application's cache driver, you may wish to change this mapping to use the Illuminate\Routing\Middleware\ThrottleRequestsWithRedis
class. This class is more efficient at managing rate limiting using Redis:
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequestsWithRedis::class,
Form Method Spoofing
HTML forms do not support PUT
, PATCH
, or DELETE
actions. So, when defining PUT
, PATCH
, or DELETE
routes that are called from an HTML form, you will need to add a hidden _method
field to the form. The value sent with the _method
field will be used as the HTTP request method:
<form action="/example" method="POST">
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
For convenience, you may use the @method
Blade directive to generate the _method
input field:
<form action="/example" method="POST">
@method('PUT')
@csrf
</form>
Accessing The Current Route
You may use the current
, currentRouteName
, and currentRouteAction
methods on the Route
facade to access information about the route handling the incoming request:
use Illuminate\Support\Facades\Route;
$route = Route::current(); // Illuminate\Routing\Route
$name = Route::currentRouteName(); // string
$action = Route::currentRouteAction(); // string
You may refer to the API documentation for both the underlying class of the Route facade and Route instance to review all of the methods that are available on the router and route classes.
Cross-Origin Resource Sharing (CORS)
Laravel can automatically respond to CORS OPTIONS
HTTP requests with values that you configure. All CORS settings may be configured in your application's config/cors.php
configuration file. The OPTIONS
requests will automatically be handled by the HandleCors
middleware that is included by default in your global middleware stack. Your global middleware stack is located in your application's HTTP kernel (App\Http\Kernel
).
{tip} For more information on CORS and CORS headers, please consult the MDN web documentation on CORS.
Route Caching
When deploying your application to production, you should take advantage of Laravel's route cache. Using the route cache will drastically decrease the amount of time it takes to register all of your application's routes. To generate a route cache, execute the route:cache
Artisan command:
php artisan route:cache
After running this command, your cached routes file will be loaded on every request. Remember, if you add any new routes you will need to generate a fresh route cache. Because of this, you should only run the route:cache
command during your project's deployment.
You may use the route:clear
command to clear the route cache:
php artisan route:clear


A movie poster is a tool which is primarily used to express the very nature of a movie.
On one hand it's main goal is to express the crucial moments, emotions and message of the film.
On the other hand it's a commercial product intending to attract a viewer, therfore it involves psychological aspects which reflect the social climate of the time and the place.
From that point of view a composition and colors of a movie poster allow us to understand more clearly the emotional side of the epoch in a given country.
Another interesting aspect of this topic is discovering the correlation between movie success (its popularity and box office) and its poster colors.
This analysis can be used for determining the optimal balance of colors for a movie poster.
In this research the correlation between movie poster colors and genre is also considered. The obtained information allows determining the patterns for each genre and can be used for creating new posters
radically different from those that customers are used to in that increasing a probability of commercial success.
The dataset consists of 97520 records obtained randomly from www.themoviedb.org
The number of movies is increasing exponencially throughout years. Though it is interesting that there was a stagnation in 2008-2010 and in 2017-2018.
I would suggest that it is due to the random nature of sampling, i.e. I used only about 1/7 of the whole cinematography and even though the sampling is based on the uniform distribution I would not ommit that kind of issue.
There is a significant drop in 2020 which is obviously connected with the corona virus crisis. The numbers for 2021 and 2022 are not the final yet and it will be curious to see how it changes.
It's curious that initially the ratio of black color was pretty high which cn be connected with presence of only black and white movies. Then in the forties the amount of black decreased which I connect with the desire of the society to compensate the negative emotions during and after the 2nd World War. In foloowing periods the amount of black increases, while white and other colors are less used. The reason for that is probably the increase in the amount of horror and thriller movies in this period, which use black as a main color.
As it was expected the horror and thriller movies are the ones that use black the most. In the same time comedy is the one that uses primarily white colors. I would also admit the extensive use of RGB colors in animation, adventure and family movies. Another observation is that the orange color (255,136,0) which is usually associated with skin color is used the least in science fiction whereas the use of blue (0,136,255) is the most extensive in this genre. The reason for that is probably that science fiction posters involve technology which is associated with blue and usually replaces the human presence (orange color).
I considered countries with the highest GDP in this barplot. It's interesting that India demonstrates a significant variety of used RGB colours and lack of black compared to other ones. Russian movie posters do not involve much use of white color, though it has RGB usage comparable with India. Canadian movie posters are the ones that use black the most (from the considered countries). It is hard to tell the distinct reasons for the observed differences but probably it has cultural reasons.
I tried to define the most used color from RGB range expecting to get a colourful map, but it turns out that the most used color is orange. This fact can be explained by the presence of people on the posters regardless of country.