<commit_before>package main

import (
	"fmt"
	"log"
	"syscall"
	"time"
	"unsafe"

	"github.com/koron/go-waveout"
)

const (
	rate = 8000
	freq = 400
)

func stage2(h syscall.Handle, hdr *waveout.WaveHdr) {
	r := waveout.Write(h, hdr, uint32(unsafe.Sizeof(*hdr)))
	if r != 0 {
		log.Printf("Write() failed: %s", r.Error())
		return
	}
	log.Printf("Write() done")
	time.Sleep(2 * time.Second)
	r = waveout.Reset(h)
	if r != 0 {
		log.Printf("Reset() failed: %s", r.Error())
		return
	}
}

func stage1(h syscall.Handle) {
	d := make([]byte, rate*2)
	l := rate / freq
	for i := range d {
		if i%l < l/2 {
			d[i] = 128 + 64
		} else {
			d[i] = 128 - 64
		}
	}
	hdr := waveout.WaveHdr{
		Data:         &d[0],
		BufferLength: uint32(len(d)),
		Flags:        uint32(waveout.WHDR_BEGINLOOP | waveout.WHDR_ENDLOOP),
		Loops:        1,
	}
	r := waveout.PrepareHeader(h, &hdr, uint32(unsafe.Sizeof(hdr)))<commit_msg>const for sec<commit_after>package main

import (
	"fmt"
	"log"
	"syscall"
	"time"
	"unsafe"

	"github.com/koron/go-waveout"
)

const (
	rate = 8000
	freq = 400
	sec = 2
)

func stage2(h syscall.Handle, hdr *waveout.WaveHdr) {
	r := waveout.Write(h, hdr, uint32(unsafe.Sizeof(*hdr)))
	if r != 0 {
		log.Printf("Write() failed: %s", r.Error())
		return
	}
	log.Printf("Write() done")
	time.Sleep(sec * time.Second)
	r = waveout.Reset(h)
	if r != 0 {
		log.Printf("Reset() failed: %s", r.Error())
		return
	}
}

func stage1(h syscall.Handle) {
	d := make([]byte, rate*sec)
	l := rate / freq
	for i := range d {
		if i%l < l/2 {
			d[i] = 128 + 64
		} else {
			d[i] = 128 - 64
		}
	}
	hdr := waveout.WaveHdr{
		Data:         &d[0],
		BufferLength: uint32(len(d)),
		Flags:        uint32(waveout.WHDR_BEGINLOOP | waveout.WHDR_ENDLOOP),
		Loops:        1,
	}
	r := waveout.PrepareHeader(h, &hdr, uint32(unsafe.Sizeof(hdr)))
{'fraction_non_alphanumeric': 0.18465753424657536, 'fraction_numerical': 0.03671232876712329, 'mean_word_length': 3.048780487804878, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2683130', 'n_tokens_mistral': 899, 'n_tokens_neox': 803, 'n_words': 169}