# Commands covered: sound concatenate
#

package require -exact snack 2.2

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

test concatenate-1.1 {concatenate command} {
  set s1 [snack::sound snd1 -load ex1.wav]
  set s2 [snack::sound snd2]
  $s2 length 1000
  $s2 concatenate $s1
  set res [list [$s2 sample 999] [$s2 sample 6000] [$s2 sample 11000]]
  $s1 destroy
  $s2 destroy
  set res
} {0 7443 779}

test concatenate-1.2 {concatenate command, stereo} {
  set s1 [snack::sound snd1 -channels 2]
  set s2 [snack::sound snd2 -channels 2]
  $s1 length 1000
  $s1 sample 999 1 2
  $s2 length 1000
  $s2 sample 0 3 4
  $s1 concatenate $s2
  set res [list [$s1 sample 999] [$s1 sample 1000]]
  $s1 destroy
  $s2 destroy
  set res
} {{1 2} {3 4}}

test concatenate-1.3 {concatenate command, 3 channels} {
  set s1 [snack::sound snd1 -channels 3]
  set s2 [snack::sound snd2 -channels 3]
  $s1 length 1000
  $s1 sample 999 1 2 3
  $s2 length 1000
  $s2 sample 0 4 5 6
  $s1 concatenate $s2
  set res [list [$s1 sample 999] [$s1 sample 1000]]
  $s1 destroy
  $s2 destroy
  set res
} {{1 2 3} {4 5 6}}

# cleanup
::tcltest::cleanupTests
return
