Comments (13)
Does the DAC show that it is receiving DSD input? If so that means at least the DoP markers are being correctly transmitted.
from sfbaudioengine.
As an aside, you might consider waiting for the sample rate change to take effect (using a property listener) before calling player.play
, although I don't think that's related to your issue.
from sfbaudioengine.
Yes, the DAC can display DSD64 when playing.
I try to set delay ( 2γ5γ10 seconds ) calling player.play after set sample rate, it nothing change, still noise in the sound.
And I used another DAC OPPO Sonica DAC to test, it ok (both on DSD64 and DSD128 test file), no noise in the sound,
DAC display DSD on 2.822 MHz / DSD on 5.644 MHz.
I noticed if set delay ( 2 seconds ) after set sample rate, play DSD128 file, DAC( McIntosh C47 ) also can display DSD128, if not, will display 352.8kHz
Test code below:
if let device = AudioObject.make(player.outputDeviceID) as? AudioDevice {
try device.setSampleRate(sampleRate)
}
var bFlag = true
let date_old = Date()
let tmDelay = 2
while bFlag {
let elapsed = Date().timeIntervalSince(date_old)
let duration = Int(elapsed)
bFlag = duration < tmDelay
usleep(1000 * 500) // 0.5 secodns
}
if let decoder = try item.decoder(enableDoP: enableDoP) {
try player.play(decoder)
}
from sfbaudioengine.
Since it's working with the OPPO DAC I assume the problem lies with the non-deterministic amount of time it is taking for the McIntosh to change sample rates. What happens when using a property listener and not calling play
until the sample rate change is complete?
from sfbaudioengine.
Thank your suggestion.
I am so sorry that I am a newer for swift, actually I donβt know how to write property listener for device sample rate change in this project now.
I think your mean is , I need to check device sample rate, ensure call player.play must be after change is completed, so I write a timer instead property listener ( I'm not sure if it's the right way ), run this code, it seem device always change sample rate correct, because log output like below, but noise did not disappear :
2021-11-01 14:14:35.332241+0800 SimplePlayer[87590:1506374] [AudioObject] Setting device 0x3a sample rate to 176400.00 Hz
-------------------------------------------------
176400.0 -> device.actualSampleRate : 176400.0 device.sampleRate : 176400.0
Sample rate is changed!
That is my test code:
func play(item: PlaylistItem) {
do {
var enableDoP = false
var sampleRate : Double = 48 * 1000
if let audioFile = try? AudioFile(readingPropertiesAndMetadataFrom: item.url) {
let bitPerChannel = audioFile.properties.bitsPerChannel
sampleRate = audioFile.properties.sampleRate ?? sampleRate
enableDoP = bitPerChannel == 1
if (enableDoP) {
sampleRate = sampleRate / 16
}
if let device = AudioObject.make(player.outputDeviceID) as? AudioDevice {
try device.setSampleRate(sampleRate)
}
let context = [sampleRate, enableDoP, item] as [Any]
Timer.scheduledTimer(
timeInterval : 1.0,
target: self,
selector: #selector(checkDevice),
userInfo: context,
repeats: true)
}
}
catch let error {
NSApp.presentError(error)
}
}
checkDevice function
var runCount = 5
@objc func checkDevice(timer: Timer)
{
guard let context = timer.userInfo as? [Any] else { return }
let setting_sampleRate :Double = context[0] as! Double
let enableDoP :Bool = context[1] as! Bool
let item :PlaylistItem = context[2] as! PlaylistItem
do {
if let device = AudioObject.make(player.outputDeviceID) as? AudioDevice {
let actualSampleRate : Double = try device.actualSampleRate()
let sampleRate : Double = try device.actualSampleRate()
print("-------------------------------------------------")
print(setting_sampleRate," -> device.actualSampleRate : ", actualSampleRate, "device.sampleRate : ", sampleRate)
if fabs(setting_sampleRate - actualSampleRate) < Double.ulpOfOne {
print("Sample rate is changed!")
timer.invalidate()
runCount = 5
if let decoder = try item.decoder(enableDoP: enableDoP) {
try player.play(decoder)
}
}
}
}
catch let error {
print(error)
timer.invalidate()
runCount = 5
}
runCount -= 1
if runCount == 0 {
timer.invalidate()
runCount = 5
}
}
from sfbaudioengine.
Hi,
I can write property listener now, and when I test nominalSampleRate property is work, but actualSampleRate no work ( listener never be trigger ), when I use nominalSampleRate property for trigger to call player.play still noise.
It seem can't detect actualSampleRate change from my DAC (both OPPO and McIntosh).
do I correct about property listener ?
I edited updateDeviceMenu() func, add code below:
if isActiveDevice {
devicePopUpButton.select(deviceMenuItem)
/// make property listener for nominalSampleRate
/// actualSampleRate, nominalSampleRate
if let device = AudioObject.make(currentOutputDeviceID) as? AudioDevice {
/// TODO : need to unregister listener when device change
/// TODO : when sample rate not change will not to play
try device.whenSelectorChanges(AudioObjectSelector.nominalSampleRate, perform: {_ in
DispatchQueue.main.async {
self.onSampleRateChanged()
}
})
}
}
function onSampleRateChanged:
func onSampleRateChanged() {
do {
let item : PlaylistItem? = self.currentItem
let enableDoP : Bool = self.currentEnableDop
if let decoder = try item!.decoder(enableDoP: enableDoP) {
try player.play(decoder)
}
print("nominalSampleRate is changed")
} catch let error {
NSApp.presentError(error)
}
}
code in the function func play(item: PlaylistItem)
self.currentItem = item
self.currentEnableDop = enableDoP
if let device = AudioObject.make(player.outputDeviceID) as? AudioDevice {
try device.setSampleRate(sampleRate)
}
from sfbaudioengine.
I assume the problem happens on more than one file? Are you able to test with both a .dsf and .dsdiff file?
from sfbaudioengine.
Yes, I test another DSD file that is .dff format, same thing happended.
from sfbaudioengine.
I'm not quite sure yet what the problem could be so I don't have any great suggestions to diagnose the issue. Does ensuring the player is stopped before changing the sample rate have any effect?
Also, does the McIntosh DAC use the CoreAudio drivers?
from sfbaudioengine.
I aways click stop button first and then select new DSD file, so I think the player stoped.
McIntosh C-47 only supply ASIO driver for Win, but say support DoP on OS X without driver.
Thank you for your replay. I'll check things out again if there are any updates.
from sfbaudioengine.
Hi,
I think maybe I found the problem about the noise.
When I use MIDI tools, my DAC MC-47 has three options under 176.4 kHz,
If I select 2ch 24-bit Integer and 2ch 32-bit Integer, the noise will be gone, and 2ch 16-bit Integer the noise will be back.
And I try to find the way to select correct options with Core Audio API, it seem no support, do you have any suggests ?
from sfbaudioengine.
Those formats are properties of the AudioStream objects in the output scope of the AudioDevice. A stream has a virtual and physical format. You can inspect them using the AudioDevice
and AudioStream
classes.
You can try searching kAudioDevicePropertyStreams
, kAudioStreamPropertyVirtualFormat
, or kAudioStreamPropertyAvailableVirtualFormats
for more information.
from sfbaudioengine.
Yes, change physical format with AudioStream can set the device to 2ch 24Bit 176.4kHz in my DAC, thank you for you help !
from sfbaudioengine.
Related Issues (20)
- SFBFLACDecoder - decodeIntoBuffer - not decoding all frames HOT 5
- Add .podspec for Cocoapods HOT 1
- Looping a decoder region doesn't work HOT 1
- Unable to stream MP3/WAV and possibly other formats HOT 3
- playReturningError failure HOT 6
- How to changed speed
- Importing Package HOT 2
- macOS 14+ dependencies? HOT 6
- Unable to convert some audio formats
- AudioDevice HOT 3
- Encoding .wav to .oggOpus HOT 8
- Does the pre-render callback still exist? HOT 1
- Issues queueing and dequeueing Opus tracks HOT 8
- Retain cycle in `SFBAudioPlayerNode` prevents deallocation HOT 1
- MOD files repeat endlessly HOT 4
- Replace dumb with libopenmpt for MOD decoding
- SPM can't add package HOT 1
- Unable to import CSFBAudioEngine HOT 7
- Lack of content type detection
- Package framework BUG in the background HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sfbaudioengine.