AVAudioPlayerNode vs AVAudioUnitSampler volume

There is a noticable difference in volume between the sample audio file loaded into AVAudioPlayerNode and AVAudioUnitSampler.


Is there a configuration I might set to make these different nodes the same volume?


Here's a simple example project: https://github.com/gmcerveny/VolumeDemo


But the gist of it is:


    func initEngine() {
        let mixer = engine.mainMixerNode
       
        engine.attach(sampler)
        engine.connect(sampler, to: mixer, format: sampler.outputFormat(forBus: 0))
       
        engine.attach(player)
        engine.connect(player, to: mixer, format: sampler.outputFormat(forBus: 0))
       
        let soundUrl = Bundle.main.url(forResource: "C1", withExtension: ".wav",subdirectory: "Sounds")!
        try! sampler.loadAudioFiles(at: [soundUrl])
       
        let file = try! AVAudioFile(forReading: soundUrl)
        buffer = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: AVAudioFrameCount(file.length))
        try! file.read(into: buffer)
       
        try! engine.start()
    }
    @IBAction func playerTouched(_ sender: Any) {
        player.scheduleBuffer(buffer, completionHandler: nil)
        player.play()
    }
   
    @IBAction func samplerTouched(_ sender: Any) {
        sampler.startNote(24, withVelocity: 127, onChannel: 0)
    }