• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ssfrr/AudioIO.jl: [UNMAINTAINED] - Simple Audio IO in Julia

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ssfrr/AudioIO.jl

开源软件地址:

https://github.com/ssfrr/AudioIO.jl

开源编程语言:

Julia 100.0%

开源软件介绍:

AudioIO.jl

Build Status Pkgs Status Coverage Status

This package is no longer being maintained. I suggest you check out the JuliaAudio family of packages for audio-related work in Julia

AudioIO interfaces to audio streams, including real-time recording, audio processing, and playback through your sound card using PortAudio. It also supports reading and writing audio files in a variety of formats. It is under active development and the low-level API could change, but the basic functionality (reading and writing files, the play function, etc.) should be stable and usable by the general Julia community.

File I/O

File I/O is handled by libsndfile, so we can support a wide variety of file and sample formats. Use the AudioIO.open function to open a file. It has the same API as the built-in Base.open, but returns an AudioFile type. Opening an audio file and reading its contents into an array is as simple as:

f = AudioIO.open("data/never_gonna_give_you_up.wav")
data = read(f)
close(f)

Or to hand closing the file automatically (including in the case of unexpected exceptions), we support the do block syntax:

data = AudioIO.open("data/never_gonna_let_you_down.wav") do f
    read(f)
end

By default the returned array will be in whatever format the original audio file is (Float32, UInt16, etc.). We also support automatic conversion by supplying a type:

data = AudioIO.open("data/never_gonna_run_around.wav") do f
    read(f, Float32)
end

Basic Array Playback

Arrays in various formats can be played through your soundcard. Currently the native format that is delivered to the PortAudio backend is Float32 in the range of [-1, 1]. Arrays in other sizes of float are converted. Arrays in Signed or Unsigned Integer types are scaled so that the full range is mapped to [-1, 1] floating point values.

To play a 1-second burst of noise:

julia> v = rand(44100) * 0.1
julia> play(v)

AudioNodes

In addition to the basic play function you can create more complex networks of AudioNodes in a render chain. In fact, when using the basic play to play an Array, behind the scenes an instance of the ArrayPlayer type is created and added to the master AudioMixer inputs. Audionodes also implement a stop function, which will remove them from the render graph. When an implicit AudioNode is created automatically, such as when using play on an Array, the play function should return the audio node that is playing the Array, so it can be stopped if desired.

To explictly do the same as above:

julia> v = rand(44100) * 0.1
julia> player = ArrayPlayer(v)
julia> play(player)

To generate 2 sin tones:

julia> osc1 = SinOsc(440)
julia> osc2 = SinOsc(660)
julia> play(osc1)
julia> play(osc2)
julia> stop(osc1)
julia> stop(osc2)

All AudioNodes must implement a render function that can be called to retreive the next block of audio.

AudioStreams

AudioStreams represent an external source or destination for audio, such as the sound card. The play function attaches AudioNodes to the default stream unless a stream is given as the 2nd argument.

AudioStream is an abstract type, which currently has a PortAudioStream subtype that writes to the sound card, and a TestAudioStream that is used in the unit tests.

Currently only 1 stream at a time is supported so there's no reason to provide an explicit stream to the play function. The stream has a root mixer field which is an instance of the AudioMixer type, so that multiple AudioNodes can be heard at the same time. Whenever a new frame of audio is needed by the sound card, the stream calls the render method on the root audio mixer, which will in turn call the render methods on any input AudioNodes that are set up as inputs.

Installation

To install the latest release version, simply run

julia> Pkg.add("AudioIO")

If you want to install the lastest master, it's almost as easy:

julia> Pkg.clone("AudioIO")
julia> Pkg.build("AudioIO")



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
toivoh/Debug.jl: Prototype interactive debugger for Julia发布时间:2022-07-09
下一篇:
ninjin/juliacon2017_dl_workshop发布时间:2022-07-09
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap