Documentation ¶
Overview ¶
Package melrose is for programming music melodies in Go
Index ¶
- Constants
- Variables
- func AppendStorexList(b *bytes.Buffer, isFirstParameter bool, list []Sequenceable)
- func ContainsInt(list []int, value int) bool
- func Duration(h HasValue) time.Duration
- func DurationToFraction(bpm float64, d time.Duration) float32
- func Float(h HasValue) float32
- func FractionToDurationParts(f float64) (fraction float32, dotted bool)
- func FractionToString(f float32) string
- func IndexOf(v interface{}) interface{}
- func InspectValue(ctx Context, v interface{})
- func Int(h HasValue) int
- func IsBlackKey(nr int) bool
- func IsDebug() bool
- func IsIdenticalTo(left, right Sequenceable) bool
- func MIDIToNoteParts(nr int) (name string, octave int, accidental int)
- func NotesEventsToFile(events []NoteEvent, name string)
- func ParseIntervalStrategy(s string) intervalStrategy
- func ParseVelocity(plusmin string) (velocity int)
- func PrintValue(ctx Context, v interface{})
- func QuantizeFraction(durationFactor float32) (fraction float32, dotted bool, ok bool)
- func Storex(v interface{}) string
- func String(h HasValue) string
- func StringFromNoteGroup(notes []Note) string
- func ToggleDebug() bool
- func ValueOf(v interface{}) interface{}
- func VelocityToDynamic(v int) string
- func WholeNoteDuration(bpm float64) time.Duration
- type AudioDevice
- type BassTablature
- type BeatAction
- type BeatSchedule
- type Beatmaster
- func (b *Beatmaster) BIAB() int
- func (b *Beatmaster) BPM() float64
- func (b *Beatmaster) BeatsAndBars() (int64, int64)
- func (b *Beatmaster) Plan(bars int64, seq Sequenceable)
- func (b *Beatmaster) Reset()
- func (b *Beatmaster) SetBIAB(biab int)
- func (b *Beatmaster) SetBPM(bpm float64)
- func (b *Beatmaster) SettingNotifier(handler func(LoopController))
- func (b *Beatmaster) Start()
- func (b *Beatmaster) Stop()
- type Capabilities
- type ChannelSelector
- type Chord
- func (c Chord) Inspect(i Inspection)
- func (c Chord) Notes() []Note
- func (c Chord) Replaced(from, to Sequenceable) Sequenceable
- func (c Chord) S() Sequence
- func (c Chord) Storex() string
- func (c Chord) String() string
- func (c Chord) WithFraction(f float32, dotted bool) Chord
- func (c Chord) WithInterval(i int) Chord
- func (c Chord) WithInversion(i int) Chord
- func (c Chord) WithQuality(q int) Chord
- func (c Chord) WithVelocity(v int) Chord
- type ChordProgression
- type ChordSequence
- type Condition
- type Conditional
- type ConditionalPlayContext
- type Context
- type DeviceSelector
- type Euclidean
- type Evaluatable
- type HasIndex
- type HasSequenceables
- type HasValue
- type Indexable
- type Inspectable
- type Inspection
- type Interval
- type Iterator
- type Loop
- func (l *Loop) Evaluate(ctx Context) error
- func (l *Loop) Handle(tim *Timeline, when time.Time)
- func (l *Loop) Inspect(i Inspection)
- func (l *Loop) IsPlaying() bool
- func (l *Loop) IsRunning() bool
- func (l *Loop) NextPlayAt() time.Time
- func (l *Loop) NoteChangesDo(block func(NoteChange))
- func (l *Loop) Play(ctx Context, at time.Time) error
- func (l *Loop) S() Sequence
- func (l *Loop) SetTarget(newTarget []Sequenceable)
- func (l *Loop) Stop(ctx Context) error
- func (l *Loop) Storex() string
- func (l *Loop) Target() []Sequenceable
- func (l *Loop) ToSequence(loopcount int) Sequence
- type LoopController
- type MIDINote
- type Map
- type MultiTrack
- type NameAware
- type Nextable
- type Nexter
- type Note
- func MIDItoNote(fraction float32, nr int, vel int) (Note, error)
- func MakeNote(name string, octave int, frac float32, accidental int, dot bool, velocity int) Note
- func MustParseNote(input string) Note
- func NewNote(name string, octave int, frac float32, accidental int, dot bool, velocity int) (Note, error)
- func ParseNote(input string) (Note, error)
- func (n Note) CheckTieableTo(t Note) error
- func (n Note) DurationAt(bpm float64) time.Duration
- func (n Note) DurationFactor() float32
- func (n Note) Equals(o Note) bool
- func (n Note) Fraction() float32
- func (n Note) HasEqualTied(o Note) bool
- func (n Note) Inspect(i Inspection)
- func (n Note) IsHearable() bool
- func (n Note) IsPedal() bool
- func (n Note) IsPedalDown() bool
- func (n Note) IsPedalUp() bool
- func (n Note) IsPedalUpDown() bool
- func (n Note) IsRest() bool
- func (n Note) MIDI() int
- func (n Note) NonFractionBasedDuration() (time.Duration, bool)
- func (n Note) Octaved(howmuch int) Note
- func (n Note) Pitched(howManySemitones int) Note
- func (n Note) Replaced(from, to Sequenceable) Sequenceable
- func (n Note) S() Sequence
- func (n Note) Storex() string
- func (n Note) Stretched(f float32) Note
- func (n Note) String() string
- func (n Note) ToNote() (Note, error)
- func (n Note) ToRest() Note
- func (n Note) WithDynamic(emphasis string) Note
- func (n Note) WithFraction(f float32, dotted bool) Note
- func (n Note) WithTiedNote(t Note) Note
- func (n Note) WithVelocity(v int) Note
- func (n Note) WithoutDynamic() Note
- type NoteChange
- type NoteChangeEvent
- type NoteConvertable
- type NoteEvent
- type NoteEventStatistics
- type NoteListener
- type NotePeriod
- type PlayContext
- type Playable
- type Print
- type Replaceable
- type Scale
- type Sequence
- func (s Sequence) At(i int) []Note
- func (s Sequence) Bars(biab int) float64
- func (s Sequence) DurationAt(bpm float64) time.Duration
- func (s Sequence) DurationFactor() float64
- func (s Sequence) Inspect(i Inspection)
- func (s Sequence) NoDynamics() Sequence
- func (s Sequence) NoFractions() Sequence
- func (s Sequence) NoRests() Sequence
- func (s Sequence) NotesDo(block func(Note))
- func (s Sequence) Octaved(howMuch int) Sequence
- func (s Sequence) Pitched(semitones int) Sequence
- func (s Sequence) PrintString(sharpOrFlatKey int) string
- func (s Sequence) Replaced(from, to Sequenceable) Sequenceable
- func (s Sequence) Reversed() Sequence
- func (s Sequence) RotatedBy(howMany int) Sequence
- func (s Sequence) S() Sequence
- func (s Sequence) SequenceJoin(t Sequence) Sequence
- func (s Sequence) Split() []Sequence
- func (s Sequence) Storex() string
- func (s Sequence) Stretched(f float32) Sequence
- func (s Sequence) String() string
- func (s Sequence) ToRest() Sequence
- func (s Sequence) W() string
- type SequenceBuilder
- type SequenceOnTrack
- type Sequenceable
- type SequenceableList
- type Stoppable
- type Storable
- type TabNote
- type TestLooper
- func (t *TestLooper) BIAB() int
- func (t *TestLooper) BPM() float64
- func (t *TestLooper) BeatsAndBars() (int64, int64)
- func (t *TestLooper) EndLoop(l *Loop)
- func (t *TestLooper) Plan(bars int64, seq Sequenceable)
- func (t *TestLooper) Reset()
- func (t *TestLooper) SetBIAB(biab int)
- func (t *TestLooper) SetBPM(bpm float64)
- func (t *TestLooper) SettingNotifier(handler func(LoopController))
- func (t *TestLooper) Start()
- func (t *TestLooper) StartLoop(l *Loop)
- func (t *TestLooper) Stop()
- func (t *TestLooper) Tick()
- type Timeline
- func (t *Timeline) BuildNotePeriods() []NotePeriod
- func (t *Timeline) EventsDo(block func(event TimelineEvent, when time.Time))
- func (t *Timeline) Len() int64
- func (t *Timeline) NoteEvents() (list []NoteEvent)
- func (t *Timeline) Play()
- func (t *Timeline) Reset()
- func (t *Timeline) Schedule(event TimelineEvent, when time.Time) error
- func (t *Timeline) ZeroStarting() *Timeline
- type TimelineEvent
- type Track
- type ValueFunction
- type ValueHolder
- type VariableStorage
Examples ¶
Constants ¶
const ( Sharp = iota Flat Eight Quarter Half Whole Dot Left Right PrintAsSpecified Major Minor // Natural Septiem Augmented Diminished Suspended2 Suspended4 // https://en.wikipedia.org/wiki/Chord_(music)#Common_types_of_chords Triad Seventh Sixth Ground Inversion1 Inversion2 Inversion3 )
const ( VelocityPPPP = 8 // ----- VelocityPPP = 20 // ---- VelocityPP = 31 // --- VelocityP = 42 // -- VelocityMP = 53 // - Normal = 59 // o VelocityMF = 64 // + VelocityF = 80 // ++ VelocityFF = 96 // +++ VelocityFFF = 112 // ++++ VelocityFFFF = 127 // +++++ )
https://www.cs.cmu.edu/~music/cmsip/readings/MIDI%20tutorial%20for%20programmers.html
const ( // OnceFromTo "once" OnceFromTo = iota // OnceFromToFrom "once-two-way" OnceFromToFrom // RepeatFromTo "repeat" RepeatFromTo // RepeatFromToFrom "repeat-two-way" RepeatFromToFrom )
const EditorLineEnd = "editor.line.end"
const EditorLineStart = "editor.line.start"
const WorkingDirectory = "shell.pwd"
WorkingDirectory is a key in a context environment.
Variables ¶
var ( Rest4 = Note{Name: "=", /* contains filtered or unexported fields */} PedalUpDown = Note{Name: "^", /* contains filtered or unexported fields */} PedalDown = Note{Name: ">", /* contains filtered or unexported fields */} PedalUp = Note{Name: "<", /* contains filtered or unexported fields */} ZeroDuration = time.Duration(0) )
var BuildTag = "dev"
var EmptySequence = Sequence{}
var N = MustParseNote
var NoLooper = zeroBeat{}
NoLooper is a Beatmaster that does not loop
var S = MustParseSequence
Functions ¶
func AppendStorexList ¶
func AppendStorexList(b *bytes.Buffer, isFirstParameter bool, list []Sequenceable)
func ContainsInt ¶
func FractionToDurationParts ¶ added in v0.44.0
func FractionToString ¶ added in v0.47.0
func InspectValue ¶
func InspectValue(ctx Context, v interface{})
func IsBlackKey ¶
func IsIdenticalTo ¶
func IsIdenticalTo(left, right Sequenceable) bool
func MIDIToNoteParts ¶ added in v0.44.0
func NotesEventsToFile ¶ added in v0.44.0
func ParseIntervalStrategy ¶
func ParseIntervalStrategy(s string) intervalStrategy
ParseIntervalStrategy return the non-exposed strategy based on the name. If unknown then return OnceFromTo ("once").
func ParseVelocity ¶
func PrintValue ¶
func PrintValue(ctx Context, v interface{})
func QuantizeFraction ¶
func StringFromNoteGroup ¶
func ToggleDebug ¶
func ToggleDebug() bool
func VelocityToDynamic ¶ added in v0.45.0
func WholeNoteDuration ¶
Types ¶
type AudioDevice ¶
type AudioDevice interface { DefaultDeviceIDs() (inputDeviceID, outputDeviceID int) // Per device specific commands Command(args []string) notify.Message // Handle generic setting HandleSetting(name string, values []interface{}) error // Play schedules all the notes on the timeline using a BPM (beats-per-minute). // Returns the end time of the last played Note. Play(condition Condition, seq Sequenceable, bpm float64, beginAt time.Time) (endingAt time.Time) HasInputCapability() bool Listen(deviceID int, who NoteListener, startOrStop bool) // if a key is pressed on a device then play or stop a function // if fun is nil then uninstall the binding OnKey(ctx Context, deviceID int, channel int, note Note, fun HasValue) error // Schedule put an event on the timeline at a begin Schedule(event TimelineEvent, beginAt time.Time) // Record(ctx Context) (*Recording, error) Reset() Close() error }
type BassTablature ¶ added in v0.47.0
type BassTablature struct {
TabNotes []TabNote
}
tabs('e3 a2 a5 d5 a5 a2 e3')
func ParseBassTablature ¶ added in v0.47.0
func ParseBassTablature(s string) (BassTablature, error)
func (BassTablature) S ¶ added in v0.47.0
func (t BassTablature) S() Sequence
func (BassTablature) Storex ¶ added in v0.47.0
func (t BassTablature) Storex() string
type BeatAction ¶
type BeatSchedule ¶
type BeatSchedule struct {
// contains filtered or unexported fields
}
BeatSchedule holds mapping between beat counts and an action (function).
func NewBeatSchedule ¶
func NewBeatSchedule() *BeatSchedule
func (*BeatSchedule) IsEmpty ¶
func (s *BeatSchedule) IsEmpty() bool
func (*BeatSchedule) Reset ¶
func (s *BeatSchedule) Reset()
func (*BeatSchedule) Schedule ¶
func (s *BeatSchedule) Schedule(beat int64, action BeatAction)
func (*BeatSchedule) Unschedule ¶
func (s *BeatSchedule) Unschedule(beat int64) []BeatAction
type Beatmaster ¶
type Beatmaster struct {
// contains filtered or unexported fields
}
Beatmaster is a LoopController
func NewBeatmaster ¶
func NewBeatmaster(ctx Context, bpm float64) *Beatmaster
func (*Beatmaster) BIAB ¶
func (b *Beatmaster) BIAB() int
func (*Beatmaster) BPM ¶
func (b *Beatmaster) BPM() float64
func (*Beatmaster) BeatsAndBars ¶
func (b *Beatmaster) BeatsAndBars() (int64, int64)
func (*Beatmaster) Plan ¶
func (b *Beatmaster) Plan(bars int64, seq Sequenceable)
Plan is part of LoopControl bars is zero-based
func (*Beatmaster) Reset ¶
func (b *Beatmaster) Reset()
func (*Beatmaster) SetBIAB ¶
func (b *Beatmaster) SetBIAB(biab int)
TODO move checks to SetBIAB in control SetBIAB will change the beats per bar, unless the master is not started.
func (*Beatmaster) SetBPM ¶
func (b *Beatmaster) SetBPM(bpm float64)
SetBPM will change the beats per minute at the next bar, unless the master is not started.
func (*Beatmaster) SettingNotifier ¶
func (b *Beatmaster) SettingNotifier(handler func(LoopController))
func (*Beatmaster) Start ¶
func (b *Beatmaster) Start()
func (*Beatmaster) Stop ¶
func (b *Beatmaster) Stop()
Stop will stop the beats. Any Loops will continue to run.
type Capabilities ¶
type Capabilities struct { AnsiColoring bool HTTPService bool ExportMIDI bool ImportMelrose bool ReceivingMIDI bool SendingMIDI bool }
func NewCapabilities ¶
func NewCapabilities() *Capabilities
type ChannelSelector ¶
type ChannelSelector struct { Target Sequenceable Number HasValue }
func NewChannelSelector ¶
func NewChannelSelector(target Sequenceable, channel HasValue) ChannelSelector
func (ChannelSelector) Channel ¶
func (c ChannelSelector) Channel() int
func (ChannelSelector) S ¶
func (c ChannelSelector) S() Sequence
func (ChannelSelector) Storex ¶
func (c ChannelSelector) Storex() string
func (ChannelSelector) Unwrap ¶
func (c ChannelSelector) Unwrap() Sequenceable
type Chord ¶
type Chord struct {
// contains filtered or unexported fields
}
https://en.wikipedia.org/wiki/Chord_(music)
func MustParseChord ¶
func (Chord) Inspect ¶
func (c Chord) Inspect(i Inspection)
func (Chord) Replaced ¶
func (c Chord) Replaced(from, to Sequenceable) Sequenceable
Replaced is part of Replaceable
func (Chord) WithFraction ¶ added in v0.45.0
func (Chord) WithInterval ¶
func (Chord) WithInversion ¶
func (Chord) WithQuality ¶
func (Chord) WithVelocity ¶ added in v0.45.0
type ChordProgression ¶
type ChordProgression struct {
// contains filtered or unexported fields
}
func NewChordProgression ¶
func NewChordProgression(root, sequence HasValue) ChordProgression
func (ChordProgression) C ¶
func (c ChordProgression) C() []Chord
func (ChordProgression) Replaced ¶
func (c ChordProgression) Replaced(from, to Sequenceable) Sequenceable
Replaced is part of Replaceable
func (ChordProgression) Storex ¶
func (c ChordProgression) Storex() string
Storex is part of Storable
type ChordSequence ¶
type ChordSequence struct {
Chords [][]Chord
}
func MustParseChordSequence ¶
func MustParseChordSequence(s string) ChordSequence
func ParseChordSequence ¶
func ParseChordSequence(input string) (ChordSequence, error)
func (ChordSequence) Inspect ¶
func (p ChordSequence) Inspect(i Inspection)
func (ChordSequence) Replaced ¶
func (p ChordSequence) Replaced(from, to Sequenceable) Sequenceable
Replaced is part of Replaceable
func (ChordSequence) S ¶
func (p ChordSequence) S() Sequence
func (ChordSequence) Storex ¶
func (p ChordSequence) Storex() string
type Conditional ¶
type Conditional interface {
Condition() Condition
}
type ConditionalPlayContext ¶
type ConditionalPlayContext struct { Context // contains filtered or unexported fields }
func (ConditionalPlayContext) Condition ¶
func (c ConditionalPlayContext) Condition() Condition
type Context ¶
type Context interface { Control() LoopController Device() AudioDevice Variables() VariableStorage Environment() *sync.Map WithCondition(c Condition) Context Capabilities() *Capabilities }
type DeviceSelector ¶
type DeviceSelector struct { Target Sequenceable ID HasValue }
func NewDeviceSelector ¶
func NewDeviceSelector(target Sequenceable, deviceID HasValue) DeviceSelector
func (DeviceSelector) DeviceID ¶
func (d DeviceSelector) DeviceID() int
func (DeviceSelector) S ¶
func (d DeviceSelector) S() Sequence
func (DeviceSelector) Storex ¶
func (d DeviceSelector) Storex() string
func (DeviceSelector) Unwrap ¶
func (d DeviceSelector) Unwrap() Sequenceable
type Euclidean ¶ added in v0.54.0
func (*Euclidean) Inspect ¶ added in v0.54.0
func (e *Euclidean) Inspect(i Inspection)
Inspect is part of Inspectable
type Evaluatable ¶
TODO makue users use Play with a Context that can have a Condition
type HasSequenceables ¶ added in v0.54.0
type HasSequenceables interface {
Sequenceables() []Sequenceable
}
type HasValue ¶
type HasValue interface {
Value() interface{}
}
func ToHasValue ¶
func ToHasValue(v interface{}) HasValue
type Indexable ¶
type Indexable interface {
At(i int) Sequenceable
}
type Inspectable ¶
type Inspectable interface {
Inspect(i Inspection)
}
type Inspection ¶
type Inspection struct { Context Context Type string Text string VariableName string Properties map[string]interface{} // contains filtered or unexported fields }
func NewInspect ¶
func NewInspect(ctx Context, varname string, value interface{}) Inspection
func (Inspection) Markdown ¶
func (i Inspection) Markdown() string
Markdown returns a markdown formatted string with inspection details
func (Inspection) String ¶
func (i Inspection) String() string
type Interval ¶
type Interval struct {
// contains filtered or unexported fields
}
Interval is a HasValue that has a Value between [from..to] and increments with [by]. If the end of the interval is reached then the Value is set to [from]. The fields of an Interval are also HasValue.
func NewInterval ¶
NewInterval creates new Interval. The initial Value is set to [from]. Specify the repeat strategy.
type Iterator ¶
type Iterator struct { Target []interface{} // contains filtered or unexported fields }
func (*Iterator) VariableName ¶ added in v0.50.1
VariableName is part of NameAware
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
func NewLoop ¶
func NewLoop(ctx Context, target []Sequenceable) *Loop
func (*Loop) NextPlayAt ¶
func (*Loop) NoteChangesDo ¶
func (l *Loop) NoteChangesDo(block func(NoteChange))
func (*Loop) SetTarget ¶
func (l *Loop) SetTarget(newTarget []Sequenceable)
func (*Loop) Target ¶
func (l *Loop) Target() []Sequenceable
func (*Loop) ToSequence ¶
type LoopController ¶
type LoopController interface { Start() Stop() Reset() SetBPM(bpm float64) BPM() float64 SetBIAB(biab int) BIAB() int BeatsAndBars() (int64, int64) Plan(bars int64, seq Sequenceable) SettingNotifier(handler func(control LoopController)) }
type MIDINote ¶
type MIDINote struct {
// contains filtered or unexported fields
}
func (MIDINote) Inspect ¶
func (m MIDINote) Inspect(i Inspection)
type Map ¶ added in v0.54.1
type Map struct { Target HasValue Replaceable HasValue Each Sequenceable }
func (Map) Replaced ¶ added in v0.54.1
func (c Map) Replaced(from, to Sequenceable) Sequenceable
func (Map) Sequenceables ¶ added in v0.54.1
func (c Map) Sequenceables() []Sequenceable
type MultiTrack ¶
type MultiTrack struct {
Tracks []HasValue
}
type Nexter ¶
type Nexter struct {
Target HasValue
}
Nexter is an empty Sequence that has a sideeffect to call Value().Next() on its target when asked for the Sequence.
type Note ¶
type Note struct { Name string // {C D E F G A B = ^ < >} Octave int Accidental int // -1 Flat, +1 Sharp, 0 Normal Dotted bool // if true then fraction is increased by half Velocity int // 1..127 // contains filtered or unexported fields }
Note represents a musical note. Notations:
2.C#3 = half duration, pitch C, sharp, octave 3, velocity default D = quarter duration, pitch D, octave 4, no accidental 8B_ = eighth duration, pitch B, octave 4, flat = = quarter rest -/+ = velocity number
http://en.wikipedia.org/wiki/Musical_Note
func MustParseNote ¶
MustParseNote returns a Note by parsing the input. Panic if it fails.
func ParseNote ¶
ParseNote reads the format <(inverse-)duration?>[CDEFGA=<^>]<accidental?><dot?><octave?>
Example ¶
n1, _ := ParseNote("2C#3") n2, _ := ParseNote("2.E_2") n3, _ := ParseNote(".F_2++") e1, _ := ParseNote("2C#") e2, _ := ParseNote("8B_") e3, _ := ParseNote("4.D") e4, _ := ParseNote("E_") t1, _ := ParseNote("2c~4c") fmt.Println(e1) fmt.Println(e2) fmt.Println(e3) fmt.Println(e4) fmt.Println(n1) fmt.Println(n2) fmt.Println(n3) fmt.Println(t1)
Output: 2C# 8B_ .D E_ 2C#3 2.E_2 .F_2++ 2C~C
func (Note) CheckTieableTo ¶ added in v0.45.0
func (Note) DurationFactor ¶
DurationFactor is the actual duration time factor Only correct if n.duration is 0 and also for each tied note ; use DurationAt otherwise
func (Note) HasEqualTied ¶ added in v0.45.0
func (Note) Inspect ¶
func (n Note) Inspect(i Inspection)
func (Note) IsHearable ¶
func (Note) IsPedalDown ¶
func (Note) IsPedalUpDown ¶
func (Note) NonFractionBasedDuration ¶
func (Note) Pitched ¶
Pitched creates a new Note with a pitch by a (positive or negative) number of semi tones
func (Note) Replaced ¶
func (n Note) Replaced(from, to Sequenceable) Sequenceable
Replaced is part of Replaceable
func (Note) WithDynamic ¶
func (Note) WithTiedNote ¶ added in v0.45.0
func (Note) WithVelocity ¶
func (Note) WithoutDynamic ¶ added in v0.45.0
type NoteChange ¶
type NoteChange struct {
// contains filtered or unexported fields
}
func NewNoteChange ¶
func NewNoteChange(isOn bool, midiNr int64, velocity int64) NoteChange
func (NoteChange) IsOn ¶
func (n NoteChange) IsOn() bool
func (NoteChange) NoteChangesDo ¶
func (n NoteChange) NoteChangesDo(block func(NoteChange))
func (NoteChange) Number ¶
func (n NoteChange) Number() int
func (NoteChange) Velocity ¶
func (n NoteChange) Velocity() int
type NoteChangeEvent ¶ added in v0.44.0
type NoteConvertable ¶
type NoteEvent ¶
type NoteEvent struct { Start time.Time `json:"start"` End time.Time `json:"end"` Number int `json:"number"` Velocity int `json:"velocity"` }
func NoteEventsFromFile ¶ added in v0.44.0
type NoteEventStatistics ¶
func NoteStatistics ¶
func NoteStatistics(list []NoteEvent) (stats NoteEventStatistics)
func (NoteEventStatistics) String ¶
func (s NoteEventStatistics) String() string
type NoteListener ¶
type NotePeriod ¶ added in v0.44.0
type NotePeriod struct {
// contains filtered or unexported fields
}
func ConvertToNotePeriods ¶ added in v0.44.0
func ConvertToNotePeriods(changes []NoteChangeEvent) (events []NotePeriod)
TODO move inside sequencebuilder ?
func NoteEventsToPeriods ¶ added in v0.44.0
func NoteEventsToPeriods(events []NoteEvent) (list []NotePeriod)
func (NotePeriod) End ¶ added in v0.44.0
func (p NotePeriod) End() time.Time
func (NotePeriod) Note ¶ added in v0.44.0
func (p NotePeriod) Note(bpm float64) Note
func (NotePeriod) Number ¶ added in v0.44.0
func (p NotePeriod) Number() int
func (NotePeriod) Quantized ¶ added in v0.44.0
func (p NotePeriod) Quantized(bpm float64) NotePeriod
func (NotePeriod) Start ¶ added in v0.44.0
func (p NotePeriod) Start() time.Time
func (NotePeriod) Velocity ¶ added in v0.44.0
func (p NotePeriod) Velocity() int
type PlayContext ¶
type PlayContext struct { LoopControl LoopController AudioDevice AudioDevice VariableStorage VariableStorage EnvironmentVars *sync.Map CapabilityFlags *Capabilities }
func (PlayContext) Capabilities ¶
func (p PlayContext) Capabilities() *Capabilities
func (PlayContext) Control ¶
func (p PlayContext) Control() LoopController
func (PlayContext) Device ¶
func (p PlayContext) Device() AudioDevice
func (PlayContext) Environment ¶
func (p PlayContext) Environment() *sync.Map
func (PlayContext) Variables ¶
func (p PlayContext) Variables() VariableStorage
func (PlayContext) WithCondition ¶
func (p PlayContext) WithCondition(c Condition) Context
type Replaceable ¶
type Replaceable interface { // Returns a new value in which any occurrences of "from" are replaced by "to". Replaced(from, to Sequenceable) Sequenceable }
type Scale ¶
type Scale struct {
// contains filtered or unexported fields
}
func ParseScale ¶
func (Scale) Replaced ¶
func (s Scale) Replaced(from, to Sequenceable) Sequenceable
Replaced is part of Replaceable
type Sequence ¶
type Sequence struct {
Notes [][]Note
}
func BuildSequence ¶
BuildSequence creates a Sequence from a slice of Note
func MustParseSequence ¶
func ParseSequence ¶
ParseSequence creates a Sequence by reading the format "Note* [Note Note*]* Note*"
func RestSequence ¶
RestSequence returns a sequence with rest notes up to <bars> respecting <biab>.
func (Sequence) DurationAt ¶ added in v0.48.0
func (Sequence) DurationFactor ¶
DurationFactor is only valid if none of its notes have a fixed duration.
func (Sequence) Inspect ¶
func (s Sequence) Inspect(i Inspection)
func (Sequence) NoDynamics ¶ added in v0.51.0
func (Sequence) NoFractions ¶ added in v0.51.0
func (Sequence) PrintString ¶
func (Sequence) Replaced ¶
func (s Sequence) Replaced(from, to Sequenceable) Sequenceable
Replaced is part of Replaceable
func (Sequence) SequenceJoin ¶
SequenceJoin returns s + t
type SequenceBuilder ¶ added in v0.44.0
type SequenceBuilder struct {
// contains filtered or unexported fields
}
func NewSequenceBuilder ¶ added in v0.44.0
func NewSequenceBuilder(periods []NotePeriod, bpm float64) *SequenceBuilder
func (*SequenceBuilder) Build ¶ added in v0.44.0
func (s *SequenceBuilder) Build() Sequence
type SequenceOnTrack ¶
type SequenceOnTrack struct { Bar HasValue Target Sequenceable }
func NewSequenceOnTrack ¶
func NewSequenceOnTrack(bar HasValue, seq Sequenceable) SequenceOnTrack
func (SequenceOnTrack) S ¶
func (s SequenceOnTrack) S() Sequence
type Sequenceable ¶
type Sequenceable interface {
S() Sequence
}
func InList ¶
func InList(s Sequenceable) []Sequenceable
func ReplacedAll ¶ added in v0.54.1
func ReplacedAll(target []Sequenceable, from, to Sequenceable) []Sequenceable
func ToSequenceable ¶
func ToSequenceable(v HasValue) Sequenceable
func UnValue ¶
func UnValue(v Sequenceable) Sequenceable
type SequenceableList ¶ added in v0.54.0
type SequenceableList struct {
Target []Sequenceable
}
func (SequenceableList) S ¶ added in v0.54.0
func (l SequenceableList) S() Sequence
type TabNote ¶ added in v0.47.0
type TabNote struct { Name string // E,A,D,G Fret int // [0..24] Dotted bool // if true then fraction is increased by half Velocity int // 1..127 // contains filtered or unexported fields }
https://www.studybass.com/lessons/reading-music/how-to-read-bass-tab/
func ParseTabNote ¶ added in v0.47.0
type TestLooper ¶
func (*TestLooper) BIAB ¶
func (t *TestLooper) BIAB() int
func (*TestLooper) BPM ¶
func (t *TestLooper) BPM() float64
func (*TestLooper) BeatsAndBars ¶
func (t *TestLooper) BeatsAndBars() (int64, int64)
func (*TestLooper) EndLoop ¶
func (t *TestLooper) EndLoop(l *Loop)
func (*TestLooper) Plan ¶
func (t *TestLooper) Plan(bars int64, seq Sequenceable)
func (*TestLooper) Reset ¶
func (t *TestLooper) Reset()
func (*TestLooper) SetBIAB ¶
func (t *TestLooper) SetBIAB(biab int)
func (*TestLooper) SetBPM ¶
func (t *TestLooper) SetBPM(bpm float64)
func (*TestLooper) SettingNotifier ¶
func (t *TestLooper) SettingNotifier(handler func(LoopController))
func (*TestLooper) Start ¶
func (t *TestLooper) Start()
func (*TestLooper) StartLoop ¶
func (t *TestLooper) StartLoop(l *Loop)
func (*TestLooper) Stop ¶
func (t *TestLooper) Stop()
func (*TestLooper) Tick ¶
func (t *TestLooper) Tick()
type Timeline ¶
type Timeline struct {
// contains filtered or unexported fields
}
Timeline is a chain of events that are placed in the future (playing).
func (*Timeline) BuildNotePeriods ¶ added in v0.44.0
func (t *Timeline) BuildNotePeriods() []NotePeriod
func (*Timeline) EventsDo ¶
func (t *Timeline) EventsDo(block func(event TimelineEvent, when time.Time))
EventsDo visits all scheduled events and calls the block for each.
func (*Timeline) NoteEvents ¶
func (*Timeline) Play ¶
func (t *Timeline) Play()
Play runs a loop to handle all the events in time. This is blocking.
func (*Timeline) Schedule ¶
func (t *Timeline) Schedule(event TimelineEvent, when time.Time) error
Schedule adds an event for a given time
func (*Timeline) ZeroStarting ¶
ZeroStarting returns a new one in which all events are shifted back in time starting at time 0.
type TimelineEvent ¶
type TimelineEvent interface { Handle(tim *Timeline, when time.Time) NoteChangesDo(block func(NoteChange)) }
TimelineEvent describes an event that can be scheduled on a Timeline.
type Track ¶
type Track struct { Title string Channel int Content map[int]Sequenceable // bar -> musical object }
func (*Track) Inspect ¶
func (t *Track) Inspect(i Inspection)
type ValueFunction ¶
type ValueFunction struct { StoreString string Function func() interface{} }
func (ValueFunction) Storex ¶
func (v ValueFunction) Storex() string
func (ValueFunction) Value ¶
func (v ValueFunction) Value() interface{}
type ValueHolder ¶
type ValueHolder struct {
Any interface{}
}
ValueHolder is decorate any object to become a HasValue.
func (ValueHolder) Storex ¶
func (h ValueHolder) Storex() string
func (ValueHolder) Value ¶
func (h ValueHolder) Value() interface{}
Source Files ¶
- beatmaster.go
- beatschedule.go
- capabilities.go
- chord.go
- chord_sequence.go
- constants.go
- context.go
- doc.go
- euclidean.go
- format_parser.go
- inspect.go
- interfaces.go
- interval.go
- iterator.go
- loop.go
- map.go
- midi_note.go
- nexter.go
- note.go
- note_event.go
- note_midi.go
- note_ops.go
- print.go
- progression.go
- scale.go
- selectors.go
- sequence.go
- sequence_builder.go
- sequence_list.go
- sequence_ops.go
- sequence_transforms.go
- tabs.go
- tabs_parser.go
- test_looper.go
- timeline.go
- times.go
- track.go
- utils.go
- valueholder.go