Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How DoPDecoder works with ASIO to output to DAC? #56

Closed
pzs7602 opened this issue May 29, 2015 · 9 comments
Closed

How DoPDecoder works with ASIO to output to DAC? #56

pzs7602 opened this issue May 29, 2015 · 9 comments

Comments

@pzs7602
Copy link

pzs7602 commented May 29, 2015

I have a Sony PHA-3 DAC supporting DoP input, I know I can use DoPDecoder with ASIO output to produce DoP data and send them to PHA-3, but how DoPDecoder be used with ASIO ? Please help me, Thanks!

@sbooth
Copy link
Owner

sbooth commented May 30, 2015

ASIO output only works with certain exaSound DACs and requires special drivers. You should be able to use a DoPDecoder with the standard core audio output as long as the equalizer is flat.

@pzs7602
Copy link
Author

pzs7602 commented Jun 4, 2015

I modify the codes in AudioPlayer.cpp for using DoPDecoder when playing .dsf audio file:

bool SFB::Audio::Player::Play(CFURLRef url)
{
    if(nullptr == url)
        return false;

//  auto decoder = Decoder::CreateForURL(url);
    SFB::CFString extension = CFURLCopyPathExtension(url);
    Decoder::unique_ptr decoder;
    if(kCFCompareEqualTo == CFStringCompare(extension, CFSTR("dsf"), kCFCompareCaseInsensitive)){
        std::cout << "dsf decoder";
        decoder = DoPDecoder::CreateForURL(url);
    }
    else if(kCFCompareEqualTo == CFStringCompare(extension, CFSTR("ape"), kCFCompareCaseInsensitive)){
        decoder = MonkeysAudioDecoder::CreateDecoder(InputSource::CreateForURL(url));
    }
    else{
        decoder = Decoder::CreateForURL(url);
    }
    return Play(decoder);
}

I connect my iPhone to Sony PHA-3 DAC through a lightning to micro-USB connector, when playing a dsf audio, the DSD indicator in PHA-3 not turn light which means no DoP data sent to PHA-3.
am I missing something in code?

@sbooth
Copy link
Owner

sbooth commented Jun 4, 2015

I don't see a problem with your code. Is it possible the iPhone output isn't bit perfect? Can you try on a desktop Mac to see if it works properly?

@pzs7602
Copy link
Author

pzs7602 commented Jun 5, 2015

I use SFBAudioEngine.xcodeproj to build a Mac desktop app, and then play a dsf audio, I 've set the audio output of my mac book pro to Sony PHA-3 connected to it via USB, but no sound an be heard. But when play mp3/aiff/aac .... , I can enjoy the music.
2015-06-05 20 02 16

@sbooth
Copy link
Owner

sbooth commented Jun 5, 2015

It looks like sample rate conversion is being performed from 176.4 to 44.1 which would explain why DoP isn't working correctly because the bit pattern would be altered. Please try setting the DAC's sample rate to match the DSF file's sample rate.

@pzs7602
Copy link
Author

pzs7602 commented Jun 7, 2015

My DAC is not able to change the sample rate, is it possible to modify the SFBAudioEngine to remain the DSD audio file's format(include sale rate) when playing dsf audio in DoP mode(say, for 2.8224Mhz DSD , when wrapped as DoP to PCM, is 176400Hz )?

@sbooth
Copy link
Owner

sbooth commented Jun 7, 2015

SFBAudioEngine attempts to do this (see the log message about the input sample rate and decoder format) but the output sample rate normally comes from the device via core audio. If your device doesn't support sample rate changes (by using SetDeviceSampleRate() in AudioOutput) you could try setting the output audio unit's kAudioUnitProperty_SampleRate on the scope kAudioUnitScope_Output within CoreAudioOutput.

@pzs7602
Copy link
Author

pzs7602 commented Jun 9, 2015

solve the problem by :

AVAudioSession *session=[AVAudioSession sharedInstance]; // get audio session
[session setPreferredSampleRate:176400 error:&err]; // request 176400 Hz

this set the preferred sample rate of input and output device to 176400
thanks!

@sbooth sbooth closed this as completed Jun 9, 2015
@eximpression
Copy link

@pzs7602 you run you code on osx but as I know AVAduioSession seem only available on the iOS? how did [session setPreferredSampleRate:176400 error:&err] work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants