User Tools

Site Tools


jpc:audio:index

jPC Audio Features

The jPC has an internal mono speaker and a stereo audio 1/8“ jack for external speakers.

Adjusting Volume

Use the alsamixer utility to adjust audio levels of each. The external speaker output is labeled “Headphone” and the internal speaker output is labeled “Line Out”.

Playing Audio from a Terminal Console

To test the left and right channels individually:

  • Left channel:
    ffplay -autoexit /usr/share/sounds/alsa/Front_Left.wav -af "pan=stereo|c0=0*c0|c1=c0"
  • Right channel:
    ffplay -autoexit /usr/share/sounds/alsa/Front_Right.wav -af "pan=stereo|c0=c0|c1=0*c0"

Playing Audio in a .NET Program

To play audio in a .NET program, consider using Alsa.NET

#:package Alsa.Net@1.0.10
 
using System;
using Alsa.Net;
using System.Reflection;
using System.Runtime.InteropServices;
 
class Program
{
    // This is needed to map the library name that Alsa.NET searches for to the exact library file
    // on the jPC.
    static IntPtr DllImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
    {
        if (libraryName == "libasound")
        {
            return NativeLibrary.Load("/usr/lib/aarch64-linux-gnu/libasound.so.2");
        }
 
        // Otherwise, fallback to default import resolver.
        return IntPtr.Zero;
    }
 
    static void Main(string[] args)
    {
        NativeLibrary.SetDllImportResolver(typeof(SoundDeviceSettings).Assembly, DllImportResolver);
 
        var soundDeviceSettings = new SoundDeviceSettings();
        using var alsaDevice = AlsaDeviceBuilder.Create(soundDeviceSettings);
 
        alsaDevice.Play("/usr/share/sounds/alsa/Front_Center.wav");
    }
}
jpc/audio/index.txt · Last modified: by 127.0.0.1