All Projects → danomatika → loaf

danomatika / loaf

Licence: GPL-3.0 license
loaf: lua, osc, and openFrameworks

Programming Languages

C++
36643 projects - #6 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to loaf

SketchSynth
A drawable OSC control panel
Stars: ✭ 46 (+24.32%)
Mutual labels:  osc, openframeworks
ofxPubSubOsc
bind OSC messages and values with only writing tiny codes on setup once.
Stars: ✭ 72 (+94.59%)
Mutual labels:  osc, openframeworks
ofxOscMidi
Midi in, OSC out with Midi thru. Based on openFrameworks
Stars: ✭ 66 (+78.38%)
Mutual labels:  osc, openframeworks
Ofxremoteui
OpenFrameworks addon serves any number of variables (bool, float, int, enum, string, ofColor) on the network, so that you can modify from outside the OF app. Includes a native OSX Client. OSC based.
Stars: ✭ 132 (+256.76%)
Mutual labels:  osc, openframeworks
ManosOsc
(Eyebeam #13 of 13) Output OSC, MIDI, and After Effects/Maya animation scripts from the Leap Motion controller.
Stars: ✭ 53 (+43.24%)
Mutual labels:  osc
Xrnx
The official Renoise Lua Scripting repository
Stars: ✭ 165 (+345.95%)
Mutual labels:  osc
Fsynth
Web-based and pixels-based collaborative synthesizer
Stars: ✭ 146 (+294.59%)
Mutual labels:  osc
Osc Js
OSC library for Node.js, Electron, Chrome Apps, Webpages or any other JS application. It comes with a customizable Plugin API for WebSocket, UDP or bridge networking
Stars: ✭ 135 (+264.86%)
Mutual labels:  osc
Hacktoberfest2021
Make your first Pull Request on Hacktoberfest 2022. Don't forget to spread love and if you like give us a ⭐️
Stars: ✭ 1,320 (+3467.57%)
Mutual labels:  osc
osc
Open Sound Control 1.0 for golang
Stars: ✭ 34 (-8.11%)
Mutual labels:  osc
Pedalino
Smart wireless MIDI foot controller for guitarists and more.
Stars: ✭ 105 (+183.78%)
Mutual labels:  osc
Swiftosc
SwiftOSC is an Open Sound Control client and server framework written in Swift.
Stars: ✭ 180 (+386.49%)
Mutual labels:  osc
vimix
Live Video Mixer
Stars: ✭ 172 (+364.86%)
Mutual labels:  osc
Atemosc
Control ATEM video switchers over the network with OSC messages
Stars: ✭ 147 (+297.3%)
Mutual labels:  osc
tinyspec-cling
tiny spectral synthesizer with livecoding support
Stars: ✭ 31 (-16.22%)
Mutual labels:  osc
Pedalinomini
Same features of Pedalino™ in a compact form.
Stars: ✭ 139 (+275.68%)
Mutual labels:  osc
Aalto Day One
Code repo for Aalto Day One branding elements
Stars: ✭ 15 (-59.46%)
Mutual labels:  openframeworks
ofxLSystemGrammar
openFrameworks addon that implements most of the string rewriting grammars described in the book "The Algorithimic Beauty of Plants"
Stars: ✭ 36 (-2.7%)
Mutual labels:  openframeworks
Chataigne
Artist-friendly Modular Machine for Art and Technology
Stars: ✭ 251 (+578.38%)
Mutual labels:  osc
Midimonster
Multi-protocol control & translation software (ArtNet, MIDI, OSC, sACN, ...)
Stars: ✭ 241 (+551.35%)
Mutual labels:  osc

loaf: lua, osc, and openFrameworks

loaf icon

Copyright (c) Dan Wilcox 2016-2020

GPL v3

For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "LICENSE.txt," in this distribution.

loaf website: danomatika.com/code/loaf

DESCRIPTION

cut off a slice of something nice

loaf is an interpreter for openFrameworks which allows you to write OF applications in the Lua scripting language. This means you can quickly create using openFrameworks but without having to compile C++ or use a heavy IDE like Xcode or Visual Studio. A built-in OSC (Open Sound Control) server enables loaf to communicate natively with other creative coding and music applications over a network connection. Additionally, a built-in Syphon server allows for streaming loaf's screen output to visual applications on the same macoS system.

Is loaf a replacement for building a native C++ application?

No. If you need to be able to include openFrameworks addons, stay with C++ for now.

So what is it for?

loaf is intended as a simple sandbox for sketching using the openFrameworks core API with a live-coding feel: make changes and see the result quickly. No compiling, no low level errors, just the basics. Think of loaf kind of like Processing without the run button.

loaf workflow

Background

loaf is the result of the author's need for a visual coding tool for performance that can run almost anywhere and communicate with tools such as Pure Data or Max MSP. Using Lua allows for loaf to react to script changes so the process of creation matches that of a dataflow environment like Pd. The native inclusion of OSC allows for coupling of loaf and other creative applications for experimentation.

loaf's design is influenced by the LÖVE Lua game engine and the Fluxus live-coding environment. It is essentially the 3rd (or 4th) iteration of a similar tool for the author's robotcowboy wearable performance project: rc-visual, originally a C++ application using SDL which read XML scene descriptions and blitted to the console framebuffer. loaf is now used as the interpreter for rc-visual which is implemented completely in Lua and works with its controller input complement, joyosc.

QUICK START

Download a release build from docs.danomatika.com/releases/loaf (currently macOS only) or build loaf after git cloning from Github

Once you have a copy of loaf, drag the loaf.app into your Applications folder (macOS) or simple run it from the loaf folder by double-clicking.

Note: A more comprehensive User Guide will be added in the future.

Basic usage

  • Drag a Lua script or folder with a main.lua onto loaf to run it
  • Either save the script somehow (in a text editor) and/or use MOD+R in loaf to reload it automatically
  • Toggle fullscreen with MOD+F
  • Script errors are shown on the app window and on the console if you run it in a terminal application
  • Prints are shown in the console (useful for debugging)

The MOD key depends on the platform: macOS COMMAND, Windows/Linux CONTROL.

Scripts, Folders, and Data Path

loaf supports opening Lua scripts (.lua) and folders which contain a main.lua file. The folder option is useful for project encapsulation. Any data file paths are automatically relative to the script's parent folder, ie. loading an image from script.lua in the following project layout:

project/script.lua
project/image.jpg

works like this:

image = of.Image()
image:load("image.jpg")

This also means Lua's require function works as expected when importing other Lua scripts or modules into the main script.

Using Lua and OF

A quick overview of using Lua and the Lua bindings for openFrameworks can be found in the ofxLua readme.

The best place to start is to look at the examples included with loaf zip and on the loaf Github repo.

There are also simple syntax lists for each of the built-in Lua bindings modules: of, osc, loaf, and syphon. These can be found in doc/modules and are a good place to start for creating auto-completion files for you favorite text editor.

Syphon Support

On macOS, loaf includes support for Syphon via a built-in server and a Lua "syphon" module with bindings for the ofxSyphonClient, ofxSyphonServer, and ofxSyphonServerDirectory classes.

Similar to the built-in OSC sender and receiver instances, the Syphon server can be accessed via loaf module Lua functions:

  • loaf.startSyphon(): start server to publish screen each frame
  • loaf.stopSyphon(): stop server
  • loaf.setSyphonName(): set server name
  • loaf.isSyphonPublishing(): is the server publishing right now?
  • loaf.getSyphonServer(): get the built-in server instance

Note: Make sure to call loaf.getSyphonServer() only after starting the server, otherwise the instance will not exist, i.e returns as "nil."

Additionally, the "syphon" module allows for using Syphon directly in Lua scripts. See examples/tests/syphon.lua.

Setting Window Size

By default, loaf starts as a 640x480 window. If you want a different resolution or to go fullscreen, you can simply call the corresponding OF functions in your script:

function setup()
    of.setWindowShape(1024, 768) -- resizes the window, like Processing size()
    of.setFullscreen(true) -- go fullscreen! also the -f commandline option
end

loaf Commandline Options

loaf has a number of options which can be set when running it from the commandline, the most basic being a script to run:

loaf path/to/script.lua

Use -h to print a usage help print:

Usage: loaf [options] [PATH [args]]

  lua, osc, and openFrameworks

Options:
  -h, --help       print usage and exit
  --version        print version and exit
  -a, --address    OSC host address to send to (default: localhost)
  -p, --port       OSC port to send to (default: 8880)
  -l, --listen     OSC port to listen on (default: 9990)
  -s, --start      start listening for OSC messages
  -f, --fullscreen start in fullscreen
  -i, --ignore     ignore script changes
  -e, --exit       exit after script error
  -r, --reload     reload timeout in secs after a script error
  --gl             try to set gl version to use ie. "4.1"
  --syphon-name    Syphon server name (default: screen)
  --syphon         start streaming screen with Syphon (macOS only)
  -v, --verbose    verbose printing

Arguments:
  PATH             optional lua script or folder to run
  args...          arguments to pass to the lua script

You can also pass arguments to the script itself by placing them after the script path:

loaf script.lua hello 123

See the argument test script for more details: examples/tests/arg.lua

macOS Terminal alias

On macOS, you can run a .app from Terminal by calling the binary hidden inside the application bundle:

/Applications/loaf.app/Contents/MacOS/loaf -h

To make this less cumbersome, you can add an alias in your .bash_profile:

alias loaf="/Applications/loaf.app/Contents/MacOS/loaf"

which allows you to call loaf with just the short alias instead:

loaf -h

Libraries

As loaf contains the Lua embedded scripting language, pure Lua libraries will work fine with it. Pre-compiled loadable Lua modules will also work as long as they are found within the require search path.

Also, a set of loaf-oriented Lua libraries is available in the loaf-ingredients repository.

BUNDLING INTO STAND-ALONE APPS

As of loaf 1.6.0, loaf projects can be "bundled" into stand-alone applications. If a "main.lua" script is found on startup, it will be used by default:

  • Windows / Linux: "data" folder next to loaf executable, ./data/
  • macOS: "data" folder within a macOS .app bundle, ../Resources/data/

The loaf executable can also be renamed.

macOS

A macOS .app bundle is basically a folder structure presented by Finder as an "application." It contains the application executable, dependent libraries, and resource files. This structure can be created & modified to make your own application which can then be distributed to run on other macOS systems.

To facilitate creating a stand-alone .app from a loaf project, the scripts/make_osxapp.sh shell script can make a copy of an existing loaf.app and use it to create a new application by copying the loaf project Lua scripts and data files inside the bundle. Additionally, it can modify metadata such as the application name, version string, and icon.

For example.

./scripts/make_osxapp.sh -l bin/loaf.app ~/Desktop/loaf-project LoafProject

will create a LoafProject.app using the files in ~/Desktop/loaf-project.

See the make_osxapp.sh help output for more info:

./scripts/make_osxapp.sh --help

BUILDING LOAF

To build loaf, you will need a copy of openFrameworks: http://openframeworks.cc/download/

loaf requires the following addons:

  • ofxLua
  • ofxOsc (included with openFrameworks)
  • ofxSyphon (optional, macOS-only)

Project files for building loaf on Windows or Linux are not included so you will need to generate them for your operating system and development environment using the OF ProjectGenerator which is included with the openFrameworks distribution.

To (re)generate project files for an existing project:

  • Click the "Import" button in the ProjectGenerator
  • Navigate to the base folder for the project ie. "loaf"
  • Click the "Update" button

If everything went Ok, you should now be able to open the generated project and build/run the example.

macOS

Open the Xcode project, select the "loaf Release" scheme, and hit "Run". Once built, the loaf.app is found in the bin directory.

Updating Xcode Project After Generation

If the project is (re)generated using the OF ProjectGenerator, the openFrameworks-Info.plist file will be overwritten and these changes can be reversed with:

git checkout openFrameworks-Info.plist

Enabling Syphon Support

Syphon support must be enabled as a compile-time option using the LOAF_USE_SYPHON C++ define.

  • Select loaf project in the Xcode file tree
  • Select loaf under PROJECT list and Build Settings tab
  • Find Other C++ flags and add: -DLOAF_USE_SYPHON

Fixing Unknown option "NSDocumentRevisionsDebugMode"

If running the project does nothing except for showing the following console output:

Unknown option "NSDocumentRevisionsDebugMode"

Edit the Debug and Release schemes and uncheck "Document Versions" in Run->Options tab.

Linux

Open the Code::Blocks .cbp and hit F9 to build. Optionally, you can build the example with the Makefile.

To build and run it on the terminal:

make
make run

Windows

Instructions for Visual Studio to be added here.

DEVELOPING

You can help develop ofxLua on GitHub: https://github.com/danomatika/loaf

Create an account, clone or fork the repo, then request a push/merge.

If you find any bugs or suggestions please log them to GitHub as well.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].