Giter Club home page Giter Club logo

fluidsynth.go's Introduction

fluidsynth.go

ci

Fluidsynth bindings for Go

功能列表 | Features

  • xxxx

  • xxxx

  • xxxx

安装说明 | Installation

go get github.com/hydrz/fluidsynth.go

使用说明 | Usage

package main

import (
	"math"
	"math/rand"
	"time"

	"github.com/hydrz/fluidsynth.go/v2"
)

func main() {
	// Create the settings
	settings := fluidsynth.NewSettings()
	if settings == nil {
		panic("Failed to create the settings!")
	}
	defer settings.Delete()

	// Change the settings
	settings.Setstr("audio.driver", "alsa")

	// Create the synthesizer
	synth := fluidsynth.NewSynth(settings)
	if synth == nil {
		panic("Failed to create the synth!")
	}
	defer synth.Delete()

	// Load a SoundFont and reset presets (so that new instruments get used from the SoundFont)
	// Depending on the size of the SoundFont, this will take some time to complete...
	sFontId := synth.SFLoad("example.sf2", true)

	if sFontId == fluidsynth.FLUID_FAILED {
		panic("Loading the SoundFont failed!")
	}

	audioDriver := fluidsynth.NewAudioDriver(settings, synth)
	if audioDriver == nil {
		panic("Failed to create the audio driver!")
	}
	defer audioDriver.Delete()

	for i := 0; i < 12; i++ {
		/* Generate a random key */
		key := 60 + uint8(math.Ceil(12*rand.Float64()))

		/* Play a note */
		synth.NoteOn(0, key, 80)

		/* Sleep for 1 second */
		time.Sleep(1 * time.Second)

		/* Stop the note */
		synth.NoteOff(0, key)
	}
}

贡献指南 | Contributing Guide

我们时刻欢迎您的贡献 | We alway welcome your contributions 👏

  1. 克隆仓库 | Fork the repository

  2. 创建 Feat_xxx 分支 | Create Feat_xxx branch

  3. 提交代码 | Commit your code

  4. 创建拉取请求 | Create Pull Request

更新日志 | Changelog

release

版权文件 | License

License: MIT

fluidsynth.go's People

Contributors

hydrz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.