1 /* 2 * Copyright 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.xr.scenecore 18 19 import android.util.Log 20 import androidx.annotation.RestrictTo 21 import androidx.xr.runtime.internal.SoundFieldAttributes as RtSoundFieldAttributes 22 import androidx.xr.runtime.internal.SpatializerConstants as RtSpatializerConstants 23 24 /** Configures ambisonics sound sources. */ 25 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) 26 public class SoundFieldAttributes(@SpatializerConstants.AmbisonicsOrder public val order: Int) { 27 28 internal val rtSoundFieldAttributes: RtSoundFieldAttributes 29 30 init { 31 val rtOrder = 32 when (order) { 33 SpatializerConstants.AMBISONICS_ORDER_FIRST_ORDER -> 34 RtSpatializerConstants.AMBISONICS_ORDER_FIRST_ORDER 35 SpatializerConstants.AMBISONICS_ORDER_SECOND_ORDER -> 36 RtSpatializerConstants.AMBISONICS_ORDER_SECOND_ORDER 37 SpatializerConstants.AMBISONICS_ORDER_THIRD_ORDER -> 38 RtSpatializerConstants.AMBISONICS_ORDER_THIRD_ORDER 39 else -> { 40 Log.e(TAG, "Unknown ambisonics order.") 41 order 42 } 43 } 44 45 rtSoundFieldAttributes = RtSoundFieldAttributes(rtOrder) 46 } 47 48 private companion object { 49 const val TAG = "SoundFieldAttributes" 50 } 51 } 52 toSoundFieldAttributesnull53internal fun RtSoundFieldAttributes.toSoundFieldAttributes(): SoundFieldAttributes { 54 return SoundFieldAttributes(this.ambisonicsOrder.ambisonicsOrderToJxr()) 55 } 56