从 “零” 做个开源音乐软件“SteadyBeat”吧!<1> 准备
换换脑子,做个音乐软件,根据调性、和弦走向(情感)、节拍、速度等需求,结合AI和一众工具,自动生成伴奏、Solo等,有点像库乐队!自己平时也用得着,暂时取名叫《SteadyBeat》吧!
- 安装 fluidsynth 2.4.5 (基于 SoundFont 2 规范的实时软件合成器。它本身没有图形用户界面,但可以通过命令行或与支持 SoundFont 的应用程序集成来使用)
brew install fluidsynth
- 我的是MacOS Sonoma 14.5,已经用了很多年了,环境很乱,所以安装的时候出现两个link的问题,一个是lame,一个是ffmpeg
# 可以看到,都有两个版本
➜ ~ brew list --versions ffmpeg(多媒体处理工具)
ffmpeg 3.1.1 7.1.1_2
➜ ~ brew list --versions lame (开源音频编码器)
lame 3.100 3.99.5# 时间久远,我也忘了当时是干什么的,索性就直接unlink了
brew unlink ffmpeg
brew link --overwrite ffmpeg --dry-run
which ffmpeg
ffmpeg --version# 查看安装版本
fluidsynth --version
- 下载一些sf2文件,我是在 generaluser 下载的,可以用 ployphone 打开和试听
- 也可以使用命令行查看音色,前边是的Bank,后边的是 Program
➜ GeneralUser-GS fluidsynth -n GeneralUser-GS.sf2
FluidSynth runtime version 2.4.5
Copyright (C) 2000-2025 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.Type 'help' for help topics.> inst 1
000-000 Grand Piano
000-001 Bright Grand Piano
000-002 Electric Grand Piano
000-003 Honky-Tonk Piano
000-004 Tine Electric Piano
000-005 FM Electric Piano
000-006 Harpsichord
000-007 Clavinet
000-008 Celeste
000-009 Glockenspiel
000-010 Music Box
000-011 Vibraphone
000-012 Marimba
000-013 Xylophone
000-014 Tubular Bells
000-015 Dulcimer
000-016 Tonewheel Organ
000-017 Percussive Organ
000-018 Rock Organ
000-019 Pipe Organ
000-020 Reed Organ
000-021 Accordion
000-022 Harmonica
000-023 Bandoneon
000-024 Nylon Guitar
000-025 Steel Guitar
000-026 Jazz Guitar
000-027 Clean Guitar
000-028 Muted Guitar
000-029 Overdrive Guitar
000-030 Distortion Guitar
000-031 Guitar Harmonics
000-032 Acoustic Bass
000-033 Finger Bass
000-034 Pick Bass
000-035 Fretless Bass
000-036 Slap Bass 1
000-037 Slap Bass 2
000-038 Synth Bass 1
000-039 Synth Bass 2
000-040 Violin
000-041 Viola
000-042 Cello
000-043 Double Bass
000-044 Tremolo Strings
000-045 Pizzicato Strings
000-046 Orchestral Harp
000-047 Timpani
000-048 Fast Strings
000-049 Slow Strings
000-050 Synth Strings 1
000-051 Synth Strings 2
000-052 Concert Choir
000-053 Voice Oohs
000-054 Synth Voice
000-055 Orchestra Hit
000-056 Trumpet
000-057 Trombone
000-058 Tuba
000-059 Muted Trumpet
000-060 French Horns
000-061 Brass Section
000-062 Synth Brass 1
000-063 Synth Brass 2
000-064 Soprano Sax
000-065 Alto Sax
000-066 Tenor Sax
000-067 Baritone Sax
000-068 Oboe
000-069 English Horn
000-070 Bassoon
000-071 Clarinet
000-072 Piccolo
000-073 Flute
000-074 Recorder
000-075 Pan Flute
000-076 Bottle Blow
000-077 Shakuhachi
000-078 Whistle
000-079 Ocarina
000-080 Square Lead
000-081 Saw Lead
000-082 Synth Calliope
000-083 Chiffer Lead
000-084 Charang
000-085 Solo Vox
000-086 5th Saw Wave
000-087 Bass & Lead
000-088 Fantasia
000-089 Warm Pad
000-090 Polysynth
000-091 Space Voice
000-092 Bowed Glass
000-093 Metal Pad
000-094 Halo Pad
000-095 Sweep Pad
000-096 Ice Rain
000-097 Soundtrack
000-098 Crystal
000-099 Atmosphere
000-100 Brightness
000-101 Goblin
000-102 Echo Drops
000-103 Star Theme
000-104 Sitar
000-105 Banjo
000-106 Shamisen
000-107 Koto
000-108 Kalimba
000-109 Bagpipes
000-110 Fiddle
000-111 Shenai
000-112 Tinker Bell
000-113 Agogo
000-114 Steel Drums
000-115 Wood Block
000-116 Taiko Drum
000-117 Melodic Tom
000-118 Synth Drum
000-119 Reverse Cymbal
000-120 Fret Noise
000-121 Breath Noise
000-122 Seashore
000-123 Birds
000-124 Telephone 1
000-125 Helicopter
000-126 Applause
000-127 Gun Shot
001-038 Synth Bass 101
001-044 Tremolo Strings Mono
001-048 Fast Strings Mono
001-049 Slow Strings Mono
001-052 Concert Choir Mono
001-056 Trumpet 2
001-057 Trombone 2
001-060 Solo French Horn
001-061 Brass Section Mono
001-080 Square Wave
001-081 Saw Wave
001-098 Synth Mallet
001-120 Cut Noise
001-121 Fl. Key Click
001-122 Rain
001-123 Dog
001-124 Telephone 2
001-125 Car-Engine
001-126 Laughing
001-127 Machine Gun
002-102 Echo Pan
002-120 String Slap
002-122 Thunder
002-123 Horse Gallop
002-124 Door Creaking
002-125 Car-Stop
002-126 Scream
002-127 Lasergun
003-122 Wind
003-123 Bird 2
003-124 Door
003-125 Car-Pass
003-126 Punch
003-127 Explosion
004-122 Stream
004-124 Scratch
004-125 Car-Crash
004-126 Heart Beat
005-122 Bubbles
005-124 Windchime
005-125 Siren
005-126 Footsteps
006-125 Train
007-125 Jet Plane
008-004 Chorused Tine EP
008-005 Chorused FM EP
008-006 Coupled Harpsichord
008-014 Church Bells
008-016 Detuned Tnwl. Organ
008-017 Detuned Perc. Organ
008-019 Pipe Organ 2
008-021 Italian Accordion
008-024 Ukulele
008-025 12-String Guitar
008-026 Hawaiian Guitar
008-027 Chorused Clean Gt.
008-028 Funk Guitar
008-030 Feedback Guitar
008-031 Guitar Feedback
008-038 Acid Bass
008-039 Beef FM Bass
008-048 Orchestra Pad
008-050 Synth Strings 3
008-061 Brass Section 2
008-062 Synth Brass 3
008-063 Synth Brass 4
008-080 Sine Wave
008-081 Doctor Solo
008-107 Taisho Koto
008-115 Castanets
008-116 Concert Bass Drum
008-117 Melodic Tom 2
008-118 808 Tom
008-125 Starship
009-014 Carillon
009-125 Burst Noise
011-000 Piano & Str.-Fade
011-001 Piano & Str.-Sus
011-004 Tine & FM EPs
011-005 Piano & FM EP
011-006 Harpsichord noVel
011-008 Tinkling Bells
011-011 Vibraphone No Trem.
011-014 Bell Tower
011-016 Tonewheel Org noVel
011-017 Percussive Org noVel
011-018 Rock Organ noVel
011-019 Pipe Organ noVel
011-020 Reed Organ noVel
011-029 Wah Guitar (CC21)
011-038 Techno Bass
011-039 Pulse Bass
011-049 Velo Strings
011-050 Synth Strings 4
011-051 Synth Strings 5
011-061 Brass Section 3
011-078 Whistlin'
011-081 Sawtooth Stab
011-088 Harpsi Pad
011-089 Solar Wind
011-096 Mystery Pad
011-098 Synth Chime
011-100 Bright Saw Stack
011-119 Cymbal Crash
011-121 Filter Snap
011-122 Howling Winds
011-127 Interference
012-000 Bell Piano
012-004 Bell Tine EP
012-006 Coupled Harpsi noVel
012-010 Christmas Bells
012-016 Detun Tnwl Org noVel
012-017 Detun Perc Org noVel
012-019 Pipe Organ 2 noVel
012-027 Clean Guitar 2
012-038 Mean Saw Bass
012-048 Full Orchestra
012-049 Velo Strings Mono
012-080 Square Lead 2
012-081 Saw Lead 2
012-088 Fantasia 2
012-089 Solar Wind 2
012-119 Tambourine
012-122 White Noise Wave
012-127 Shooting Star
013-048 Woodwind Choir
013-080 Square Lead 3
013-081 Saw Lead 3
013-088 Night Vision
016-025 Mandolin
024-075 Tin Whistle
025-075 Tin Whistle Nm
026-075 Tin Whistle Or
120-000 Standard 1 Kit
120-001 Standard 2 Kit
120-002 Standard 3 Kit
120-008 Room Kit
120-016 Power Kit
120-024 Electronic Kit
120-025 808/909 Kit
120-026 Dance Kit
120-032 Jazz Kit
120-040 Brush Kit
120-048 Orchestral Kit
120-056 SFX Kit
120-127 CM-64/32L Kit
128-000 Standard 1
128-001 Standard 2
128-002 Standard 3
128-008 Room
128-016 Power
128-024 Electronic
128-025 808/909
128-026 Dance
128-032 Jazz
128-040 Brush
128-048 Orchestral
128-056 SFX
128-127 CM-64/32L
- 在开发环境中安装pyfluidsynth 1.3.4,别装错了,还有个fluidsynth,这是是0.2版本
- 测试下声音,我选的 011-000 Piano & Str.-Fade
import fluidsynth
import timesf2_path = "/Users/chenpenghao/Downloads/GeneralUser-GS/GeneralUser-GS.sf2"# 初始化 FluidSynth
fs = fluidsynth.Synth()
fs.start(driver="coreaudio") # 加载 SoundFont 文件
sfid = fs.sfload(sf2_path)bank = 11 # 你之前看到的 Bank 128
prog = 0 # Program 0
fs.program_select(0, sfid, bank, prog) # 选择音色# 播放音符
fs.noteon(0, 60, 100) # 播放中音C(MIDI音符60)
time.sleep(1) # 播放1秒
fs.noteoff(0, 60) # 停止音符# 删除 Synth 实例
fs.delete()