chendeben 6 сар өмнө
parent
commit
d4ca67fb91

+ 10 - 10
entry/src/main/ets/common/util/EqualizerManager.ets

@@ -45,18 +45,18 @@ export class EqualizerManager {
     { frequency: 16000, label: '16kHz', gain: 0 }
   ];
 
-  // 内置预设
+  // 内置预设 - 增益值增大以获得更明显的效果
   public static readonly BUILT_IN_PRESETS: EqualizerPreset[] = [
     { id: 'normal', name: '正常', gains: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], isCustom: false },
-    { id: 'pop', name: '流行', gains: [-1, 2, 4, 4, 2, 0, -1, -1, -1, -1], isCustom: false },
-    { id: 'rock', name: '摇滚', gains: [4, 3, 1, 0, -1, 0, 2, 3, 4, 4], isCustom: false },
-    { id: 'jazz', name: '爵士', gains: [3, 2, 1, 2, -2, -2, 0, 1, 2, 3], isCustom: false },
-    { id: 'classical', name: '古典', gains: [4, 3, 2, 1, -1, -1, 0, 2, 3, 4], isCustom: false },
-    { id: 'bass_boost', name: '低音增强', gains: [6, 5, 4, 2, 0, 0, 0, 0, 0, 0], isCustom: false },
-    { id: 'treble_boost', name: '高音增强', gains: [0, 0, 0, 0, 0, 1, 2, 4, 5, 6], isCustom: false },
-    { id: 'vocal', name: '人声增强', gains: [-2, -1, 0, 2, 4, 4, 2, 0, -1, -2], isCustom: false },
-    { id: 'dance', name: '舞曲', gains: [5, 4, 2, 0, 0, -2, -1, 2, 3, 4], isCustom: false },
-    { id: 'acoustic', name: '原声', gains: [3, 2, 1, 1, 2, 2, 2, 3, 2, 1], isCustom: false }
+    { id: 'pop', name: '流行', gains: [-2, 3, 6, 6, 3, 0, -2, -2, -2, -2], isCustom: false },
+    { id: 'rock', name: '摇滚', gains: [6, 5, 2, 0, -2, 0, 3, 5, 6, 6], isCustom: false },
+    { id: 'jazz', name: '爵士', gains: [5, 3, 2, 3, -3, -3, 0, 2, 3, 5], isCustom: false },
+    { id: 'classical', name: '古典', gains: [6, 5, 3, 2, -2, -2, 0, 3, 5, 6], isCustom: false },
+    { id: 'bass_boost', name: '低音增强', gains: [10, 8, 6, 3, 0, 0, 0, 0, 0, 0], isCustom: false },
+    { id: 'treble_boost', name: '高音增强', gains: [0, 0, 0, 0, 0, 2, 4, 6, 8, 10], isCustom: false },
+    { id: 'vocal', name: '人声增强', gains: [-4, -2, 0, 4, 6, 6, 4, 0, -2, -4], isCustom: false },
+    { id: 'dance', name: '舞曲', gains: [8, 6, 3, 0, 0, -3, -2, 3, 5, 6], isCustom: false },
+    { id: 'acoustic', name: '原声', gains: [5, 4, 2, 2, 3, 3, 3, 5, 4, 2], isCustom: false }
   ];
 
   // 当前状态

+ 7 - 5
ijkplayer/oh_modules/@types/libijkplayer_audio_napi.so/index.d.ts

@@ -18,19 +18,19 @@ export declare class newIjkPlayerAudio {
   constructor(Id: string, isVideo: boolean);
   _native_setup_audio(xcomponentId: string): void;
   _nativeOpenlog(xcomponentId: string): void;
-  _setDataSource(xcomponentId: string, url:string): void;
-  _setOption(xcomponentId: string, category:string,key:string,value:string): void;
-  _setOptionLong(xcomponentId: string, category:string,key:string,value:string): void;
+  _setDataSource(xcomponentId: string, url: string): void;
+  _setOption(xcomponentId: string, category: string, key: string, value: string): void;
+  _setOptionLong(xcomponentId: string, category: string, key: string, value: string): void;
   _prepareAsync(xcomponentId: string): void;
   _start(xcomponentId: string): void;
   _stop(xcomponentId: string): void;
   _pause(xcomponentId: string): void;
   _reset(xcomponentId: string): void;
   _release(xcomponentId: string): void;
-  _seekTo(xcomponentId: string, msec:string): void;
+  _seekTo(xcomponentId: string, msec: string): void;
   _isPlaying(xcomponentId: string): boolean;
   _getDuration(xcomponentId: string): number;
-  _setMessageListener(xcomponentId: string, messageCallBack:Function): void;
+  _setMessageListener(xcomponentId: string, messageCallBack: Function): void;
   _getCurrentPosition(xcomponentId: string): number;
   _getAudioSessionId(xcomponentId: string): number;
   _setPropertyFloat(xcomponentId: string, property: string, value: string): void;
@@ -45,4 +45,6 @@ export declare class newIjkPlayerAudio {
   _getAudioCodecInfo(xcomponentId: string): string;
   _getMediaMeta(xcomponentId: string): string;
   _native_setup(xcomponentId: string): void;
+  _setEqualizerEnabled(xcomponentId: string, enabled: boolean): void;
+  _setEqualizerGains(xcomponentId: string, gains: number[]): void;
 }

+ 3 - 1
ijkplayer/src/main/cpp/ijksdl/audio/ijksdl_equalizer.h

@@ -26,7 +26,9 @@ static const float EQ_CENTER_FREQUENCIES[EQ_BAND_COUNT] = {
 };
 
 // 滤波器带宽 (Q factor)
-#define EQ_DEFAULT_Q 1.41f
+// Q 值越小,每个频段影响的范围越宽
+// 对于 10 频段均衡器,推荐 0.707 ~ 1.0
+#define EQ_DEFAULT_Q 0.707f
 
 // 单个 Biquad 滤波器状态
 typedef struct BiquadFilter {