Skip to content

Commit

Permalink
disable tagger on not main, created first example
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodz committed Dec 24, 2023
1 parent 4f73270 commit b27f405
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: tagger
on:
push:
branches:
- "*"
- "main"

jobs:
tagger:
Expand Down
55 changes: 54 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,57 @@

# Dependency directories (remove the comment below to include it)
# vendor/
executable
executable

## All files with audio format
# Ignore standart audio files
*.3gp
*.aa
*.aac
*.aax
*.act
*.aiff
*.alac
*.amr
*.ape
*.au
*.awb
*.dss
*.flac
*.gsm
*.m4a
*.m4b
*.m4p
*.mp3
*.mpc
*.ogg
*.oga
*.mogg
*.ulaw
*.opus
*.pcm
*.ra
*.rm
*.raw
*.rf64
*.sln
*.tta
*.voc
*.vox
*.wav
*.wma
*.webm
*.8svx
*.cda
# Ignore raw audio files
*.raw
*.wv
*.mid
*.midi
*.mod
*.mpa
*.mp1
*.mp2
*.mp3
*.ul
*.al
58 changes: 58 additions & 0 deletions examples/transcoder/ulaw_2_wav.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package main

import (
"fmt"
"math/rand"
"os"

"github.com/sopro-dev/sopro-core/audio"
"github.com/sopro-dev/sopro-core/audio/formats/pcm"
"github.com/sopro-dev/sopro-core/audio/formats/ulaw"
)

func main() {
numSamples := 80000
numChannels := 2
samplesPerSecond := 44100

inputData := make([]byte, numSamples*numChannels)
for i := 0; i < numSamples; i++ {
// Calculate the current second
currentSecond := i / samplesPerSecond

// Generate noise for the first second, then silence for the second second
if currentSecond%2 == 0 {
sample := byte(127 * (2.0*rand.Float64() - 1.0)) // Generate random noise
inputData[i*numChannels] = sample
inputData[i*numChannels+1] = sample
} else {
inputData[i*numChannels] = 0 // Silence
inputData[i*numChannels+1] = 0 // Silence
}
}

audioInfo := audio.AudioInfo{
SampleRate: 44100,
Channels: numChannels,
BitDepth: 16,
FloatFormat: false,
}

transcoder := audio.NewTranscoder(&pcm.PCMFormat{}, &ulaw.ULawFormat{})
outputData := transcoder.Transcode(inputData, audioInfo)

// Process the output data as needed...
fmt.Println(outputData[:200])

// Store the output data to a file...
f, err := os.Create("output.ul")
if err != nil {
panic(err)
}
defer f.Close()

_, err = f.Write(outputData)
if err != nil {
panic(err)
}
}

0 comments on commit b27f405

Please sign in to comment.