Skip to content

Commit

Permalink
updated README.md on test coverage, updated makefile for test cov
Browse files Browse the repository at this point in the history
  • Loading branch information
deftio committed Aug 11, 2024
1 parent 27655e4 commit 89860f8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,31 @@ Finally, it can be in some systems that we can't turn off the audio input sourc
* [wikipedia on Companding](https://en.wikipedia.org/wiki/Companding)
* [University of British Columbia lab on Companding](https://people.ece.ubc.ca/edc/4550.jan2018/lab2.pdf)

### Code Coverage
Code coverage is achieved using gcov from the gcc test suite. To see the code coverage:

```bash
make clean
make
./test-library.out
gcov companders.c
This generates the file lib.c.gcov, which can be viewed in any text editor. Lines with #### have never been run.
```


## Versions

* 1.0.6 08 Aug 2024 -- added ci testing
* 1.0.5 30 May 2024 -- cleaned up release
* 1.0.4 30 May 2024 -- add ulaw, updated docs, added full test
* 1.0.4 23 Jan 2023 -- updated docs
* 1.0.3 28 Jul 2019 -- updated docs, ver example
* 1.0.2 15 Jul 2016 -- updated README.md to markdown format. updated license to be OSI compliant. no code changes. some minor doc updates. Thanks to John R Strohm giving me the nudge to update the docs here.
* 1.0.1 3 Sep 2012 -- original release in github
* 1.0.6 08 Aug 2024 -- added ci testing
* 1.0.5 30 May 2024 -- cleaned up release
* 1.0.4 30 May 2024 -- add ulaw, updated docs, added full test
* 1.0.4 23 Jan 2023 -- updated docs
* 1.0.3 28 Jul 2019 -- updated docs, ver example
* 1.0.2 15 Jul 2016 -- updated README.md to markdown format. updated license to be OSI compliant. no code changes. some minor doc updates. Thanks to John R Strohm giving me the nudge to update the docs here.
* 1.0.1 3 Sep 2012 -- original release in github

## License

See attached LICENSE.txt file (OSI approved BSD 2.0)
See attached LICENSE.txt file (OSI approved BSD 2 Clause)

Copyright (c) 2001-2024, M. A. Chatterjee < deftio at deftio dot com >
All rights reserved.
Expand All @@ -228,3 +240,5 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


5 changes: 3 additions & 2 deletions companders.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ static DIO_s8 MuLawLogTable[256] =
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
};
#define cBias 0x84
#define cClip 32635


DIO_s8 DIO_LinearToULaw(DIO_s16 sample)
{
const DIO_s16 cBias=0x84;
const DIO_s16 cClip=32635;
DIO_s32 sign, exponent, mantissa;
DIO_s8 compandedValue;

Expand Down
8 changes: 4 additions & 4 deletions companders_fulltest.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ unsigned char LinearToMuLawSample(short sample)
//=========================================================

void test_LinearToALaw() {
DIO_s16 testSamples[] = {-2460, -338, -1, 499, 980};
DIO_s8 expectedResults[] = {22, 64, 85, -54, -5};
DIO_s16 testSamples[] = {-2460, -338, -1, 499, 980, 32700};
DIO_s8 expectedResults[] = {22, 64, 85, -54, -5, -86};
size_t numSamples = sizeof(testSamples) / sizeof(testSamples[0]);
for (size_t i = 0; i < numSamples; ++i) {
DIO_s8 companded = DIO_LinearToALaw(testSamples[i]);
Expand All @@ -104,8 +104,8 @@ void test_ALawToLinear() {
}

void test_LinearToULaw() {
DIO_s16 testSamples[] = {-2460, -338, -1, 499, 7000};
DIO_s8 expectedResults[] = { 59, 98, 127, 220, 164};
DIO_s16 testSamples[] = {-2460, -338, -1, 499, 7000,32700};
DIO_s8 expectedResults[] = { 59, 98, 127, 220, 164, -128};
size_t numSamples = sizeof(testSamples) / sizeof(testSamples[0]);
for (size_t i = 0; i < numSamples; ++i) {
DIO_s8 companded = DIO_LinearToULaw(testSamples[i]);
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TEST_OBJ = companders.o companders_fulltest.o
$(CC) -c -o $@ $< $(CFLAGS_TEST)

compandit: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) -lm
$(CC) -o $@ $^ $(CFLAGS_TEST) -lm

companders_fulltest: $(TEST_OBJ)
$(CC) -o $@ $^ $(CFLAGS_TEST) -lm
Expand All @@ -22,4 +22,4 @@ test: companders_fulltest
./companders_fulltest

clean:
rm *.o compandit companders_fulltest -f
rm *.o *.asm *.lst *.sym *.rel *.s *.gc* -f *.info

0 comments on commit 89860f8

Please sign in to comment.