User Tools

Site Tools


ai:examples:csv_score_board:csv_score_board

Ai Example

CSV Score Board

A simple score board which updates live from data in a CSV file. This is just the data from Arran's highly recommendable video lesson on creating this - do not miss to watch this: https://www.youtube.com/watch?v=bSW4dxtdnBA

by: Mr. A., July 2016
published: https://www.youtube.com/watch?v=bSW4dxtdnBA
tested in version: 10.2
downloads: csv_simple_patch_v1.scb – first steps (see images below)
csv_simple_patch_v2.scb – two cells read (see images below)
csv_simple_patch_v3.scb – final version with texture
example.csv – simple csv file example
scores.csv – the example score file

Hint: click the images to show them larger.

Background

This is an example for the use of the CSV File Reader module: a score board for a sports event which updates live from data in a csv spreadsheet, enhanced with a nice background texture.

It is highly recommended to watch the video as this exactly shows how such a task is solved, from the beginning until the least details.

Screenshots of the various states of creating this patch:

CSV Score Board, first steps CSV Score Board, two cells read CSV Score Board, final version CSV Score Board, final version -- subpatch

Used Modules

How it works

  • the first picture - csv_v1.png - shows the first steps – a csv file is loaded, and the contents from one cell is rendered and displayed
  • the second picture - csv_v2.png - is a little advanced – now, two cells are read and redered, and merged into one output
  • the third picture - csv_v3.png - is the final version – three lines à 2 cells are read and merged, and a nice background is imported as texture. For clarity, the logic per line is put into a subpatch (see csv_v3_sub.png which has resemblance with csv_v2.png, don't you think?)

The core are the CSV File Reader modules which each read one cell from a given csv file (when trying this yourself make sure you have proper files loaded, e.g. the ones available as downloads above).

Various Constant modules are used in order to define used constants, e.g. the column and row to read, the canvas size, font size e.g.

Vector Join here combines two numeric values into one vector which is required as Texture Size parameter for the String Texture modules which are used to render the string.

Texture lets us import an image file as texture - which is then (like the textures rendered from the texts) rendered by a Rectangle module.

Each cell's contents is positioned with Scale and Translate, and various Render Merge modules merge all the parts into one stream, while BlendMode makes sure all the textures are transparent where black.

The video shows perfectly how subpatches can be created: simply draw a selection box around all the modules you want to be grouped together and press Ctrl + G. This way, the selected modules are put into a subpatch, together with a Patch IO if needed - and any cross-patching is already done. It is then very easy to duplicate the subpatch. Here, there is a dedicated subpatch per line.

further ideas

This is a very good example to brush-up your patching skills. Here are some thoughts of how this can be developed further:

  • you can 'centralise' most of the constants on the top level, and then e.g. only increment them per line
  • you can expose the row index, so that it's easy to see and set the row each line is supposed to show
  • also the csv file to be read can be centralised on the top level (show the port Source File Name and use the module Filename As String)
  • and of course this patch can be slightly modified so that it can be used in the Performance page
ai/examples/csv_score_board/csv_score_board.txt · Last modified: 2018/11/01 16:35 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki