Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: Source/core/platform/audio/HRTFPanner.h

Issue 14636011: Support multiple HRTFDatabases for different sample-rates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 24
25 #ifndef HRTFPanner_h 25 #ifndef HRTFPanner_h
26 #define HRTFPanner_h 26 #define HRTFPanner_h
27 27
28 #include "core/platform/audio/FFTConvolver.h" 28 #include "core/platform/audio/FFTConvolver.h"
29 #include "core/platform/audio/Panner.h" 29 #include "core/platform/audio/Panner.h"
30 #include "modules/webaudio/DelayDSPKernel.h" 30 #include "modules/webaudio/DelayDSPKernel.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 class HRTFDatabase;
35
34 class HRTFPanner : public Panner { 36 class HRTFPanner : public Panner {
35 public: 37 public:
36 explicit HRTFPanner(float sampleRate); 38 HRTFPanner(float sampleRate, HRTFDatabase*);
37 virtual ~HRTFPanner(); 39 virtual ~HRTFPanner();
38 40
39 // Panner 41 // Panner
40 virtual void pan(double azimuth, double elevation, const AudioBus* inputBus, AudioBus* outputBus, size_t framesToProcess); 42 virtual void pan(double azimuth, double elevation, const AudioBus* inputBus, AudioBus* outputBus, size_t framesToProcess);
41 virtual void reset(); 43 virtual void reset();
42 44
43 size_t fftSize() const { return fftSizeForSampleRate(m_sampleRate); } 45 size_t fftSize() const { return fftSizeForSampleRate(m_sampleRate); }
44 static size_t fftSizeForSampleRate(float sampleRate); 46 static size_t fftSizeForSampleRate(float sampleRate);
45 47
46 float sampleRate() const { return m_sampleRate; } 48 float sampleRate() const { return m_sampleRate; }
47 49
48 virtual double tailTime() const OVERRIDE; 50 virtual double tailTime() const OVERRIDE;
49 virtual double latencyTime() const OVERRIDE; 51 virtual double latencyTime() const OVERRIDE;
50 52
51 private: 53 private:
52 // Given an azimuth angle in the range -180 -> +180, returns the correspondi ng azimuth index for the database, 54 // Given an azimuth angle in the range -180 -> +180, returns the correspondi ng azimuth index for the database,
53 // and azimuthBlend which is an interpolation value from 0 -> 1. 55 // and azimuthBlend which is an interpolation value from 0 -> 1.
54 int calculateDesiredAzimuthIndexAndBlend(double azimuth, double& azimuthBlen d); 56 int calculateDesiredAzimuthIndexAndBlend(double azimuth, double& azimuthBlen d);
55 57
58 HRTFDatabase* m_database;
59
56 float m_sampleRate; 60 float m_sampleRate;
57 61
58 // We maintain two sets of convolvers for smooth cross-faded interpolations when 62 // We maintain two sets of convolvers for smooth cross-faded interpolations when
59 // then azimuth and elevation are dynamically changing. 63 // then azimuth and elevation are dynamically changing.
60 // When the azimuth and elevation are not changing, we simply process with o ne of the two sets. 64 // When the azimuth and elevation are not changing, we simply process with o ne of the two sets.
61 // Initially we use CrossfadeSelection1 corresponding to m_convolverL1 and m _convolverR1. 65 // Initially we use CrossfadeSelection1 corresponding to m_convolverL1 and m _convolverR1.
62 // Whenever the azimuth or elevation changes, a crossfade is initiated to tr ansition 66 // Whenever the azimuth or elevation changes, a crossfade is initiated to tr ansition
63 // to the new position. So if we're currently processing with CrossfadeSelec tion1, then 67 // to the new position. So if we're currently processing with CrossfadeSelec tion1, then
64 // we transition to CrossfadeSelection2 (and vice versa). 68 // we transition to CrossfadeSelection2 (and vice versa).
65 // If we're in the middle of a transition, then we wait until it is complete before 69 // If we're in the middle of a transition, then we wait until it is complete before
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 101
98 AudioFloatArray m_tempL1; 102 AudioFloatArray m_tempL1;
99 AudioFloatArray m_tempR1; 103 AudioFloatArray m_tempR1;
100 AudioFloatArray m_tempL2; 104 AudioFloatArray m_tempL2;
101 AudioFloatArray m_tempR2; 105 AudioFloatArray m_tempR2;
102 }; 106 };
103 107
104 } // namespace WebCore 108 } // namespace WebCore
105 109
106 #endif // HRTFPanner_h 110 #endif // HRTFPanner_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698