Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
au: add util function calc_nsamp() (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 authored Apr 27, 2022
1 parent 22389d4 commit 38ab363
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ add_definitions(-DVERSION="${PROJECT_VERSION}")
add_library(${PROJECT_NAME}
src/aac/aac.c
src/au/fmt.c
src/au/util.c
src/aubuf/aubuf.c
src/aubuf/ajb.c
src/auconv/auconv.c
Expand Down
2 changes: 2 additions & 0 deletions include/rem_au.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ enum aufmt {

size_t aufmt_sample_size(enum aufmt fmt);
const char *aufmt_name(enum aufmt fmt);

uint32_t calc_nsamp(uint32_t srate, uint8_t channels, uint16_t ptime);
2 changes: 1 addition & 1 deletion src/au/mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# Copyright (C) 2010 Creytiv.com
#

SRCS += au/fmt.c
SRCS += au/fmt.c au/util.c
23 changes: 23 additions & 0 deletions src/au/util.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @file util.c Audio utility functions
*
* Copyright (C) 2022 Commend.com - [email protected]
*/

#include <re.h>
#include <rem_au.h>


/**
* Calculate number of samples from sample rate, channels and packet time
*
* @param srate Sample rate in [Hz]
* @param channels Number of channels
* @param ptime Packet time in [ms]
*
* @return Number of samples
*/
uint32_t calc_nsamp(uint32_t srate, uint8_t channels, uint16_t ptime)
{
return srate * channels * ptime / 1000;
}

0 comments on commit 38ab363

Please sign in to comment.