Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apps: add Auracast USB sample with LC3 codec #1659

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
445 changes: 445 additions & 0 deletions apps/auracast_usb/include/tusb_config.h

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions apps/auracast_usb/include/usb_audio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef H_USB_AUDIO_
#define H_USB_AUDIO_

#include <stdint.h>

typedef void (* usb_audio_sample_rate_cb_t)(uint32_t);

/* Set default sample rate, should only be used before USB is initialized */
void usb_desc_sample_rate_set(uint32_t sample_rate);

#endif /* H_USB_AUDIO_ */
46 changes: 46 additions & 0 deletions apps/auracast_usb/pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

pkg.name: apps/auracast_usb
pkg.type: app
pkg.description: Auracast sample application.

pkg.author: "Krzysztof Kopyściński"
pkg.email: "[email protected]"
pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:

pkg.deps:
- "@apache-mynewt-core/sys/config"
- nimble/host
- nimble/host/util
- nimble/host/services/gap
- nimble/host/store/config
- "@apache-mynewt-core/kernel/os"
- "@apache-mynewt-core/sys/console"
- "@apache-mynewt-core/sys/log"
- "@apache-mynewt-core/sys/stats"
- "@apache-mynewt-core/sys/sysinit"
- "@apache-mynewt-core/sys/id"
- "@apache-mynewt-core/hw/usb/tinyusb"
- "@apache-mynewt-nimble/nimble/host/audio/services/auracast"
- "@apache-mynewt-nimble/ext/liblc3"
- "@apache-mynewt-nimble/ext/libsamplerate"

pkg.init:
audio_usb_init: 402
45 changes: 45 additions & 0 deletions apps/auracast_usb/src/app_priv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef H_APP_PRIV_
#define H_APP_PRIV_

#include <syscfg/syscfg.h>

#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif

#define AUDIO_CHANNELS MYNEWT_VAL(AURACAST_CHAN_NUM)
#define AUDIO_SAMPLE_SIZE sizeof(int16_t)
#define AUDIO_PCM_SAMPLE_RATE MYNEWT_VAL(USB_AUDIO_OUT_SAMPLE_RATE)

#define LC3_FRAME_DURATION (MYNEWT_VAL(LC3_FRAME_DURATION))
#define LC3_SAMPLING_FREQ (MYNEWT_VAL(LC3_SAMPLING_FREQ))
#define LC3_BITRATE (MYNEWT_VAL(LC3_BITRATE))
#define LC3_FPDT (LC3_SAMPLING_FREQ * LC3_FRAME_DURATION / 1000000)
#define BIG_NUM_BIS (MIN(AUDIO_CHANNELS, MYNEWT_VAL(BIG_NUM_BIS)))

struct chan {
void *encoder;
uint16_t handle;
};

extern struct chan chans[AUDIO_CHANNELS];
#endif /* H_APP_PRIV_ */
Loading
Loading