Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to set sequence somehow on model:samples? #18

Open
frostmark opened this issue Feb 2, 2023 · 1 comment
Open

Is it possible to set sequence somehow on model:samples? #18

frostmark opened this issue Feb 2, 2023 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@frostmark
Copy link

Hi, I would be very grateful if you show example how set sequence programmatically :)

@bh90210
Copy link
Owner

bh90210 commented Feb 3, 2023

hello,
something like this?

package main

import (
	"time"

	m "github.com/bh90210/models"
)

func main() {
	p, err := m.NewProject(m.SAMPLES)
	if err != nil {
		panic(err)
	}

	// Custom song struct.
	song := struct {
		track map[m.Voice]map[int]bool
	}{make(map[m.Voice]map[int]bool)}

	// Init each track's map.
	song.track[m.T1] = make(map[int]bool)
	song.track[m.T2] = make(map[int]bool)
	song.track[m.T3] = make(map[int]bool)
	song.track[m.T4] = make(map[int]bool)

	// Track 1.
	song.track[m.T1][0] = true
	song.track[m.T1][2] = true
	song.track[m.T1][4] = true
	song.track[m.T1][6] = true
	song.track[m.T1][8] = true
	song.track[m.T1][10] = true
	song.track[m.T1][12] = true
	song.track[m.T1][14] = true

	// Track 2.
	song.track[m.T2][0] = true
	song.track[m.T2][4] = true
	song.track[m.T2][8] = true
	song.track[m.T2][12] = true

	// Track 3.
	song.track[m.T3][1] = true
	song.track[m.T3][5] = true
	song.track[m.T3][9] = true
	song.track[m.T3][13] = true

	// Track 4.
	song.track[m.T4][0] = true
	song.track[m.T4][1] = true
	song.track[m.T4][7] = true
	song.track[m.T4][8] = true
	song.track[m.T4][9] = true
	song.track[m.T4][13] = true
	song.track[m.T4][15] = true

	var i int
	for {
		if i > 15 {
			i = 0
		}

		for t, v := range song.track {
			if trigger, ok := v[i]; ok && trigger {
				p.Note(m.Voice(t), m.A4, 100, 150)
			}
		}

		time.Sleep(250 * time.Millisecond)

		i++
	}
}

@bh90210 bh90210 self-assigned this Feb 3, 2023
@bh90210 bh90210 added the documentation Improvements or additions to documentation label Feb 3, 2023
Repository owner deleted a comment from katsavav Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants
@frostmark @bh90210 and others