Skip to content

Commit

Permalink
Merge pull request #168 from NickCulbertson/Sampler-Load-Delay
Browse files Browse the repository at this point in the history
Add SFZ Load Delay
  • Loading branch information
NickCulbertson authored Oct 28, 2024
2 parents 1baba79 + 408579d commit 858da7e
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ class InstrumentSFZConductor: ObservableObject, HasAudioEngine {
}

init() {
// Load SFZ file with Dunne Sampler
if let fileURL = Bundle.main.url(forResource: "Sounds/sqr", withExtension: "SFZ") {
instrument.loadSFZ(url: fileURL)
} else {
Log("Could not find file")
DispatchQueue.main.async {
// Load SFZ file with Dunne Sampler.
// This needs to be loaded after a delay the first time
// to get the correct Settings.sampleRate if it is 48_000.
if let fileURL = Bundle.main.url(forResource: "Sounds/sqr", withExtension: "SFZ") {
self.instrument.loadSFZ(url: fileURL)
} else {
Log("Could not find file")
}
self.instrument.masterVolume = 0.15
}
instrument.masterVolume = 0.15
engine.output = instrument
}
}
Expand Down

0 comments on commit 858da7e

Please sign in to comment.