mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
feat: remove unreleased parameter from Play function
The VMs now release all envelopes by default, so this mechanism was useless / did not actually start them as unreleased even when you thought they did.
This commit is contained in:
parent
9f7bbce761
commit
b6815f70cb
@ -21,7 +21,6 @@ func main() {
|
|||||||
help := flag.Bool("h", false, "Show help.")
|
help := flag.Bool("h", false, "Show help.")
|
||||||
directory := flag.String("o", "", "Directory where to output all files. The directory and its parents are created if needed. By default, everything is placed in the same directory where the original song file is.")
|
directory := flag.String("o", "", "Directory where to output all files. The directory and its parents are created if needed. By default, everything is placed in the same directory where the original song file is.")
|
||||||
play := flag.Bool("p", false, "Play the input songs (default behaviour when no other output is defined).")
|
play := flag.Bool("p", false, "Play the input songs (default behaviour when no other output is defined).")
|
||||||
unreleased := flag.Bool("u", false, "Start song with all oscillators unreleased.")
|
|
||||||
//start := flag.Float64("start", 0, "Start playing from part; given in the units defined by parameter `unit`.")
|
//start := flag.Float64("start", 0, "Start playing from part; given in the units defined by parameter `unit`.")
|
||||||
//stop := flag.Float64("stop", -1, "Stop playing at part; given in the units defined by parameter `unit`. Negative values indicate render until end.")
|
//stop := flag.Float64("stop", -1, "Stop playing at part; given in the units defined by parameter `unit`. Negative values indicate render until end.")
|
||||||
//units := flag.String("unit", "pattern", "Units for parameters start and stop. Possible values: second, sample, pattern, beat. Warning: beat and pattern do not take SPEED modulations into account.")
|
//units := flag.String("unit", "pattern", "Units for parameters start and stop. Possible values: second, sample, pattern, beat. Warning: beat and pattern do not take SPEED modulations into account.")
|
||||||
@ -88,7 +87,7 @@ func main() {
|
|||||||
return fmt.Errorf("the song could not be parsed as .json (%v) or .yml (%v)", errJSON, errYaml)
|
return fmt.Errorf("the song could not be parsed as .json (%v) or .yml (%v)", errJSON, errYaml)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer, err := sointu.Play(bridge.NativeSynther{}, song, !*unreleased) // render the song to calculate its length
|
buffer, err := sointu.Play(bridge.NativeSynther{}, song) // render the song to calculate its length
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("sointu.Play failed: %v", err)
|
return fmt.Errorf("sointu.Play failed: %v", err)
|
||||||
}
|
}
|
||||||
|
13
synth.go
13
synth.go
@ -54,12 +54,8 @@ func Render(synth Synth, buffer AudioBuffer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Play plays the Song by first compiling the patch with the given Synther,
|
// Play plays the Song by first compiling the patch with the given Synther,
|
||||||
// returning the stereo audio buffer and the sync buffer as a result (and
|
// returning the stereo audio buffer as a result (and possible errors).
|
||||||
// possible errors). Passing 'release' as true means that all the notes are
|
func Play(synther Synther, song Song) (AudioBuffer, error) {
|
||||||
// released when the synth is created. The default behaviour during runtime
|
|
||||||
// rendering is to leave them playing, meaning that envelopes start attacking
|
|
||||||
// right away unless an explicit note release is put to every track.
|
|
||||||
func Play(synther Synther, song Song, release bool) (AudioBuffer, error) {
|
|
||||||
err := song.Validate()
|
err := song.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -68,11 +64,6 @@ func Play(synther Synther, song Song, release bool) (AudioBuffer, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("sointu.Play failed: %v", err)
|
return nil, fmt.Errorf("sointu.Play failed: %v", err)
|
||||||
}
|
}
|
||||||
if release {
|
|
||||||
for i := 0; i < 32; i++ {
|
|
||||||
synth.Release(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
curVoices := make([]int, len(song.Score.Tracks))
|
curVoices := make([]int, len(song.Score.Tracks))
|
||||||
for i := range curVoices {
|
for i := range curVoices {
|
||||||
curVoices[i] = song.Score.FirstVoiceForTrack(i)
|
curVoices[i] = song.Score.FirstVoiceForTrack(i)
|
||||||
|
@ -140,7 +140,7 @@ func (t *Tracker) saveSong(w io.WriteCloser) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tracker) exportWav(w io.WriteCloser, pcm16 bool) {
|
func (t *Tracker) exportWav(w io.WriteCloser, pcm16 bool) {
|
||||||
data, err := sointu.Play(t.synther, t.Song(), true) // render the song to calculate its length
|
data, err := sointu.Play(t.synther, t.Song()) // render the song to calculate its length
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Alert.Update(fmt.Sprintf("Error rendering the song during export: %v", err), Error, time.Second*3)
|
t.Alert.Update(fmt.Sprintf("Error rendering the song during export: %v", err), Error, time.Second*3)
|
||||||
return
|
return
|
||||||
|
@ -40,7 +40,7 @@ func TestOscillatSine(t *testing.T) {
|
|||||||
}}}
|
}}}
|
||||||
tracks := []sointu.Track{{NumVoices: 1, Order: []int{0}, Patterns: []sointu.Pattern{{64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0}}}}
|
tracks := []sointu.Track{{NumVoices: 1, Order: []int{0}, Patterns: []sointu.Pattern{{64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0}}}}
|
||||||
song := sointu.Song{BPM: 100, RowsPerBeat: 4, Score: sointu.Score{RowsPerPattern: 16, Length: 1, Tracks: tracks}, Patch: patch}
|
song := sointu.Song{BPM: 100, RowsPerBeat: 4, Score: sointu.Score{RowsPerPattern: 16, Length: 1, Tracks: tracks}, Patch: patch}
|
||||||
buffer, err := sointu.Play(bridge.NativeSynther{}, song, false)
|
buffer, err := sointu.Play(bridge.NativeSynther{}, song)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Render failed: %v", err)
|
t.Fatalf("Render failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ func TestAllRegressionTests(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not parse the .yml file: %v", err)
|
t.Fatalf("could not parse the .yml file: %v", err)
|
||||||
}
|
}
|
||||||
buffer, err := sointu.Play(bridge.NativeSynther{}, song, false)
|
buffer, err := sointu.Play(bridge.NativeSynther{}, song)
|
||||||
buffer = buffer[:song.Score.LengthInRows()*song.SamplesPerRow()] // extend to the nominal length always.
|
buffer = buffer[:song.Score.LengthInRows()*song.SamplesPerRow()] // extend to the nominal length always.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Play failed: %v", err)
|
t.Fatalf("Play failed: %v", err)
|
||||||
|
@ -43,7 +43,7 @@ func TestAllRegressionTests(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not parse the .yml file: %v", err)
|
t.Fatalf("could not parse the .yml file: %v", err)
|
||||||
}
|
}
|
||||||
buffer, err := sointu.Play(vm.GoSynther{}, song, false)
|
buffer, err := sointu.Play(vm.GoSynther{}, song)
|
||||||
buffer = buffer[:song.Score.LengthInRows()*song.SamplesPerRow()] // extend to the nominal length always.
|
buffer = buffer[:song.Score.LengthInRows()*song.SamplesPerRow()] // extend to the nominal length always.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Play failed: %v", err)
|
t.Fatalf("Play failed: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user