PassOwnPtr<AudioBus> PlatformSupport::loadPlatformAudioResource(const char* name, double sampleRate) { const WebData& resource = webKitPlatformSupport()->loadResource(name); if (resource.isEmpty()) return nullptr; return decodeAudioFileData(resource.data(), resource.size(), sampleRate); }
PassRefPtr<AudioBus> createBusFromInMemoryAudioFile(const void* data, size_t dataSize, bool mixToMono, float sampleRate) { // FIXME: the sampleRate parameter is ignored. It should be removed from the API. RefPtr<AudioBus> audioBus = decodeAudioFileData(static_cast<const char*>(data), dataSize, sampleRate); if (!audioBus.get()) return 0; // If the bus needs no conversion then return as is. if ((!mixToMono || audioBus->numberOfChannels() == 1) && audioBus->sampleRate() == sampleRate) return audioBus; return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, sampleRate); }
PassRefPtr<AudioBus> AudioBus::loadPlatformResource(const char* name, float sampleRate) { const blink::WebData& resource = blink::Platform::current()->loadResource(name); if (resource.isEmpty()) return 0; // FIXME: the sampleRate parameter is ignored. It should be removed from the API. RefPtr<AudioBus> audioBus = decodeAudioFileData(resource.data(), resource.size(), sampleRate); if (!audioBus.get()) return 0; // If the bus is already at the requested sample-rate then return as is. if (audioBus->sampleRate() == sampleRate) return audioBus; return AudioBus::createBySampleRateConverting(audioBus.get(), false, sampleRate); }
PassRefPtr<AudioBus> AudioBus::loadPlatformResource(const char* name, float sampleRate) { String absoluteFilename(makeString(DATA_DIR, "/webaudio/resources/", name, ".wav")); const WebKit::WebData& resource = WebKit::Platform::current()->loadResource(absoluteFilename.utf8().data()); if (resource.isEmpty()) return PassRefPtr<AudioBus>(); // FIXME: the sampleRate parameter is ignored. It should be removed from the API. RefPtr<AudioBus> audioBus = decodeAudioFileData(resource.data(), resource.size(), sampleRate); if (!audioBus.get()) return PassRefPtr<AudioBus>(); // If the bus is already at the requested sample-rate then return as is. if (audioBus->sampleRate() == sampleRate) return audioBus.release(); return AudioBus::createBySampleRateConverting(audioBus.get(), false, sampleRate); }