channel mixer can dump several channels (separate)
2 files changed, 61 insertions(+), 13 deletions(-)

M player/channelmixer.go
M player_lib/player_test_sdl/go.mod
M player/channelmixer.go +57 -11
@@ 29,6 29,10 @@ type ChannelMixer struct {
 	
 	// test
 	outTestFile *os.File
+	// also write separate channel buffers / outputs (test) ?
+	writeSeparateOutputChannels bool
+	// per channel files ?
+	outTestFileChannels []*os.File
 }
 
 func NewChannelMixer(s *ChannelSys) *ChannelMixer {

          
@@ 40,6 44,9 @@ func NewChannelMixer(s *ChannelSys) *Cha
 		// XXX
 		channelRenderBufAccLen: 200,
 		//channelRenderBufAccLen: 100,
+		
+		writeSeparateOutputChannels: true,
+		//writeSeparateOutputChannels: false,
 	}
 	
 	return cm

          
@@ 47,24 54,18 @@ func NewChannelMixer(s *ChannelSys) *Cha
 
 func (cm *ChannelMixer) Init() {
 	fmt.Println("ChannelMixer Init")
+}
+
+func (cm *ChannelMixer) SetNumChannels(n int) {
+	cm.createBuffers(n)
 	
 	writeToFile := true
 	
 	if writeToFile {
-		path := "/tmp/out_channel_mixer_buf.raw"
-		var err error
-		cm.outTestFile, err = os.Create(path)
-		
-		if err != nil {
-			panic(err)
-		}
+		cm.createOutFiles(n)
 	}
 }
 
-func (cm *ChannelMixer) SetNumChannels(n int) {
-	cm.createBuffers(n)
-}
-
 // XXX create channel buffers ?
 func (cm *ChannelMixer) createBuffers(n int) {
 	fmt.Println("ChannelMixer createBuffers n:", n)

          
@@ 95,6 96,40 @@ func (cm *ChannelMixer) createBuffers(n 
 }
 
 // XXX
+func (cm *ChannelMixer) createOutFiles(n int) {
+	fmt.Println("ChannelMixer createOutFiles n:", n)
+	
+	path := "/tmp/out_channel_mixer_buf.raw"
+	var err error
+	cm.outTestFile, err = os.Create(path)
+	if err != nil {
+		panic(err)
+	}
+	
+	if cm.writeSeparateOutputChannels {
+		cm.outTestFileChannels = make([]*os.File, n)
+	
+		for i := 0; i < n; i++ {
+			path := fmt.Sprintf("/tmp/out_channel_mixer_ch%02d.raw", i)
+			
+			var err error
+			cm.outTestFileChannels[i], err = os.Create(path)
+			if err != nil {
+				panic(err)
+			}
+		}
+	}
+
+}
+
+// XXX
+func (cm *ChannelMixer) GetRenderTickBufForChannel(chId int) [][2]float64 {
+	buf := cm.renderTickBuf[chId]
+	
+	return buf
+}
+
+// XXX
 func (cm *ChannelMixer) GetBufForChannel(chId int) [][2]float64 {
 
 	// sr/60 ?

          
@@ 175,7 210,10 @@ func (cm *ChannelMixer) mixbufs(buf1, bu
 }
 
 // render channel buffer
+// internal ?
 func (cm *ChannelMixer) RenderChannelTick(chId int, tickSize int) [][2]float64 {
+	printfln("ChannelMixer RenderChannelTick chId: {} tickSize: {}", chId, tickSize)
+	
 	ch := cm.channelSys.Channels[chId]
 		
 	//buf := ch.RenderBuf(tickSize)

          
@@ 250,6 288,14 @@ func (cm *ChannelMixer) RenderTick(tickS
 		DumpBufFile(cm.outTestFile, buf)
 	}
 	
+	if writeToFile && cm.writeSeparateOutputChannels {
+		n := cm.channelSys.numChannels
+		for i := 0; i < n; i++ {
+			chBuf := cm.GetRenderTickBufForChannel(i)
+			DumpBufFile(cm.outTestFileChannels[i], chBuf)
+		}
+	}
+	
 	return buf
 }
 

          
M player_lib/player_test_sdl/go.mod +4 -2
@@ 1,8 1,10 @@ 
 module kristallos.ga/tut/player_lib/player_test_sdl
 
-go 1.21
+go 1.21.3
 
-toolchain go1.23.2
+//go 1.21
+
+//toolchain go1.23.2
 
 //require "kristallos.ga/tut/player_lib"