processor

package
v0.0.0-...-a985673 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StopIteration = errors.New("ForEachEventWithTime: StopIteration")

StopIteration can be returned to return without failure.

Functions

func ForEachEventWithTime

func ForEachEventWithTime(mid *smf.SMF, yield func(time int64, track int, msg smf.Message) error) error

ForEachEventWithTime runs the given function for each event, with current absolute time and other info.

func KeySorter

func KeySorter(s []Key) func(i, j int) bool

func Process

func Process(mid *smf.SMF, config *Config, options *Options) (map[OutputKey]*smf.SMF, error)

Process processes the given MIDI file and writes the result to out.

func WithDefault

func WithDefault[T comparable](a, b T) T

func WithDefaultPtr

func WithDefaultPtr[T comparable](a *T, b T) T

Types

type Config

type Config struct {
	// Hymnbook specific configuration. Not needed in UI.
	MelodyTrackNameRE string `yaml:"melody_track_name_re,omitempty"`
	BassTrackNameRE   string `yaml:"bass_track_name_re,omitempty"`
	SoloTrackNameRE   string `yaml:"solo_track_name_re,omitempty"`

	// Organ specific configuration or override. Should be offered as UI element.
	Channel            int  `yaml:"channel,omitempty"`
	MelodyChannel      int  `yaml:"melody_channel,omitempty"`
	BassChannel        int  `yaml:"bass_channel,omitempty"`
	HoldRedundantNotes bool `yaml:"hold_redundant_notes,omitempty"`

	// Organist preferences. Should be offered as UI element.
	BPMFactor             float64 `yaml:"bpm_factor,omitempty"`
	PreludePlayerRepeat   int     `yaml:"prelude_player_repeat,omitempty"`
	PreludePlayerSleepSec float64 `yaml:"prelude_player_sleep_sec,omitempty"`

	// Interpreted fermatas. Only used for prelude and postlude. Not needed in UI.
	FermatasInPrelude  bool `yaml:"fermatas_in_prelude,omitempty"`
	FermatasInPostlude bool `yaml:"fermatas_in_postlude,omitempty"`
	FermataExtendBeats int  `yaml:"fermata_extend_beats,omitempty"`
	FermataRestBeats   int  `yaml:"fermata_rest_beats,omitempty"`

	// Misc for exporting. Not needed in UI.
	RestBetweenVersesBeats int     `yaml:"rest_between_verses_beats,omitempty"`
	WholeExportSleepSec    float64 `yaml:"whole_export_sleep_sec,omitempty"`

	// Device configuration. Used by the player.
	OutputPort string `yaml:"output_port,omitempty"`

	// DataPassword to read the data, if needed.
	DataPassword string `yaml:"data_password,omitempty"`
}

Config define global settings.

type Key

type Key struct {
	// contains filtered or unexported fields
}

type NoteTracker

type NoteTracker struct {
	// contains filtered or unexported fields
}

func NewNoteTracker

func NewNoteTracker(refcounting bool) *NoteTracker

func (NoteTracker) Handle

func (t NoteTracker) Handle(time int64, track int, msg smf.Message) (bool, int)

func (NoteTracker) NotePlaying

func (t NoteTracker) NotePlaying(k Key) bool

func (NoteTracker) NoteStart

func (t NoteTracker) NoteStart(k Key) int64

func (NoteTracker) NoteTrack

func (t NoteTracker) NoteTrack(k Key) int

func (NoteTracker) NotesPlaying

func (t NoteTracker) NotesPlaying() []Key

func (NoteTracker) Playing

func (t NoteTracker) Playing() bool

func (NoteTracker) SetNoteStart

func (t NoteTracker) SetNoteStart(k Key, time int64)

type Options

type Options struct {
	// Managed by the main program right now.
	InputFile       string `yaml:"input_file"`
	InputFileSHA256 string `yaml:"input_file_sha256,omitempty"`

	// For this module.
	Fermatas           []Pos   `yaml:"fermatas,omitempty"`
	Prelude            []Range `yaml:"prelude,omitempty"`
	Verse              []Range `yaml:"verse,omitempty"`
	Postlude           []Range `yaml:"postlude,omitempty"`
	NumVerses          int     `yaml:"num_verses,omitempty"`
	UnrolledNumVerses  int     `yaml:"unrolled_num_verses,omitempty"`
	QPMOverride        float64 `yaml:"qpm_override,omitempty"`
	BPMFactor          float64 `yaml:"bpm_factor,omitempty"`
	MaxAdjust          int64   `yaml:"max_adjust,omitempty"`
	KeepEventOrder     bool    `yaml:"keep_event_order,omitempty"`
	MelodyTracks       []int   `yaml:"melody_tracks,omitempty"`
	BassTracks         []int   `yaml:"bass_tracks,omitempty"`
	SoloTracks         []int   `yaml:"solo_tracks,omitempty"`
	FermatasInPrelude  *bool   `yaml:"fermatas_in_prelude,omitempty"`
	FermatasInPostlude *bool   `yaml:"fermatas_in_postlude,omitempty"`

	// Tags for automatic selection for prelude.
	Tags []string `yaml:"tags,omitempty"`

	// Pure comment fields. Declared here to preserve them when rewriting the checksum.
	// Can't use YAML # comments because yq loses them.
	Comment string `yaml:"_comment,omitempty"`
}

Options define file specific options.

type OutputKey

type OutputKey struct {
	// Special indicates which part this is.
	Special SpecialPart
	// Part indicates the part index in case Special is Single.
	Part int
}

func (OutputKey) String

func (k OutputKey) String() string

String converts OutputKey to a string like in a filename.

type Pos

type Pos struct {
	Bar       int
	Beat      int
	BeatNum   int
	BeatDenom int
}

func (Pos) MarshalYAML

func (p Pos) MarshalYAML() (interface{}, error)

func (Pos) ToTick

func (p Pos) ToTick(b bars) int64

func (*Pos) UnmarshalYAML

func (p *Pos) UnmarshalYAML(value *yaml.Node) error

type Range

type Range struct {
	Begin Pos `yaml:"begin"`
	End   Pos `yaml:"end"`
}

func (Range) ToTick

func (r Range) ToTick(b bars) (int64, int64)

type SpecialPart

type SpecialPart int
const (
	// Single indicates that this file covers a single part of a verse.
	Single SpecialPart = iota
	// Whole indicates that this file covers the whole output with prelude, all verses and postlude.
	Whole
	// Prelude indicates that this file covers the prelude.
	Prelude
	// Verse indicates that this file covers an entire verse.
	Verse
	// Postlude indicates that this file covers the postlude.
	Postlude
	// Panic indicates that this file just stops all notes.
	Panic
)

Jump to

Keyboard shortcuts

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