organya

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2020 License: MIT Imports: 4 Imported by: 0

README

go-organya

This module is a Go implementation of the Organya music format. It allows you to parse an Organya file and view its data.

Getting Started

Get the module:

go get pkg.nimblebun.works/go-organya

Import it:

import (
  "pkg.nimblebun.works/go-organya"
)

Create an Organya object:

org, err := organya.Open("/path/to/file.org")
if err != nil {
  panic(err)
}

// Do something with `org`

Create a playback session:

session := org.NewSession()

// ...
session.Click()

Convert your Organya data into JSON:

data, err := org.JSON()
if err != nil {
  panic(err)
}

err = ioutil.WriteFile("organya.json", data, 0644)
// ...

License and Attributions

The project is licensed under the MIT license. Huge thanks to the C library this project is based on - COrg.

Documentation

Overview

Package organya is a Go implementation of the Organya sound format. It can be used to parse Organya files and makes it possible to play them back using your own implementation.

Usage

Reading an Organya file is very simple. Just use the `Open` method and provide the path to the Organya file:

package main

import (
	"pkg.nimblebun.works/go-organya"
)

func main() {
	org, err := organya.Open("/path/to/file.org")
	if err != nil {
		panic(err)
	}

	// ...
}

You can now take advantage of the methods and properties that are exposed to you.

Index

Constants

View Source
const (
	// OrgTrackCount defines the number of possible Organya tracks in a file (16).
	OrgTrackCount int = 0x10

	// OrgNoChange is the byte that specifies that a current resource property
	// must not be different from the one before it.
	OrgNoChange uint8 = 0xFF
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Organya

type Organya struct {
	WaitValue uint16 `json:"waitValue"`
	LoopStart uint32 `json:"loopStart"`
	LoopEnd   uint32 `json:"loopEnd"`

	Tracks [OrgTrackCount]Track `json:"tracks"`
}

Organya defines the file data of an Organya file.

func Open

func Open(filename string) (*Organya, error)

Open will open the Organya file on the provided file path and return its data.

func (*Organya) JSON

func (org *Organya) JSON() ([]byte, error)

JSON will convert the current Organya object into JSON.

func (*Organya) NewSession

func (org *Organya) NewSession() *Session

NewSession will initialize a playback session on the provided Organya object.

type Resource

type Resource struct {
	Start    uint32 `json:"start"`
	Duration uint8  `json:"duration"`
	Note     uint8  `json:"note"`
	Volume   uint8  `json:"volume"`
	Pan      uint8  `json:"pan"`
}

Resource defines a single sound resource.

type Session

type Session struct {
	Angles       [OrgTrackCount]float64
	ResourceUpTo [OrgTrackCount]uint16
	CurrentClick uint32

	Org *Organya
}

Session is the playback session of an Organya object.

func (*Session) Click

func (s *Session) Click()

Click will advance in the track.

func (*Session) GetResource

func (s *Session) GetResource(track int) *Resource

GetResource will return the current resource from the provided track.

func (*Session) TrackSounding

func (s *Session) TrackSounding(track int) bool

TrackSounding specifies whether the provided track is active.

type Track

type Track struct {
	Instrument        uint8  `json:"instrument"`
	ResourceCount     uint16 `json:"resourceCount"`
	LoopStartResource uint16 `json:"loopStartResource"`

	Resources []Resource `json:"resources"`
}

Track defines a note row of a given instrument.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL