SamplerBox on Orange PI

S
Serj posted Nov 27, 14:41:

Hello!
I'm try setup SamplerBox on Orange Pi Zero with Armbian.
Joseph Ernest version plays, but has latency about 45 ms.
Alex version starts with error, seen MIDI-commands, but don't play sound.
I'm use I2S soundcard (snddaudio in "alsa -l" output). Speakertest plays without problem.
No additional hardware - no screen, no buttons (all is disclose in config.ini). Only OPI and I2S card.
Is any help me?

This is log

root@orangepizero:~/Alex/SamplerBox# aplay -l
List of PLAYBACK Hardware Devices
card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sndcodec-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: snddaudio [snddaudio], device 0: SUNXI-TDM0 snddaudio-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

root@orangepizero:~/Alex/SamplerBox# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=audiocodec
audiocodec,
Default Audio Device
dmix:CARD=audiocodec,DEV=0
audiocodec,
Direct sample mixing device
dsnoop:CARD=audiocodec,DEV=0
audiocodec,
Direct sample snooping device
hw:CARD=audiocodec,DEV=0
audiocodec,
Direct hardware device without any conversions
plughw:CARD=audiocodec,DEV=0
audiocodec,
Hardware device with all software conversions
sysdefault:CARD=snddaudio
snddaudio,
Default Audio Device
dmix:CARD=snddaudio,DEV=0
snddaudio,
Direct sample mixing device
dsnoop:CARD=snddaudio,DEV=0
snddaudio,
Direct sample snooping device
hw:CARD=snddaudio,DEV=0
snddaudio,
Direct hardware device without any conversions
plughw:CARD=snddaudio,DEV=0
snddaudio,
Hardware device with all software conversions
sysdefault:CARD=sndhdmi
sndhdmi,
Default Audio Device
dmix:CARD=sndhdmi,DEV=0
sndhdmi,
Direct sample mixing device
dsnoop:CARD=sndhdmi,DEV=0
sndhdmi,
Direct sample snooping device
hw:CARD=sndhdmi,DEV=0
sndhdmi,
Direct hardware device without any conversions
plughw:CARD=sndhdmi,DEV=0
sndhdmi,
Hardware device with all software conversions

root@orangepizero:~/Alex/SamplerBox# sudo python samplerbox.py

START CONFIG IMPORT

CONFIG: Looking for config.ini in /boot/samplerbox/
CONFIG: looking for config.ini in /SamplerBox/
CONFIG used: ./config.ini
SYSTEM_MODE = 1
MAX_POLYPHONY = 40
MIDI_CHANNEL = 1
BUFFERSIZE = 512
SAMPLERATE = 44100
LATENCY = 5
BOXRELEASE = 30
RAM_LIMIT_PERCENTAGE = 65
SAMPLES_DIR = None
SAMPLES WARNING: dir None not found. Looking for USB drive: /media
SAMPLES WARNING: USB ( /media ) not found or not mounted. Looking for SD card dir: /samples
SAMPLES WARNING: dir /samples not found. Looking for default: ./media
SAMPLES DIR: ./media
USE_BUTTONS = False
USE_HD44780_16X2_LCD = False
USE_HD44780_20X4_LCD = False
USE_FREEVERB = False
USE_TONECONTROL = False
USE_I2C_7SEGMENTDISPLAY = False
USE_GUI = False
INVERT_SUSTAIN = False
VELOCITY_CURVE = 0
PRINT_LCD_MESSAGES = False
PRINT_MIDI_MESSAGES = False
AUDIO_DEVICE_ID = 1
AUDIO_DEVICE_NAME = snddaudio
PRESET_BASE = 0
GPIO_LCD_RS = 5
GPIO_LCD_E = 6
GPIO_LCD_D4 = 12
GPIO_LCD_D5 = 13
GPIO_LCD_D6 = 16
GPIO_LCD_D7 = 26
GPIO_7SEG = 1
PANIC_KEY = None
[!] Warning: No MIDI control has been assigned to PANIC_KEY
BUTTON_LEFT_MIDI = None
[!] Warning: No MIDI control has been assigned to BUTTON_LEFT_MIDI
BUTTON_RIGHT_MIDI = None
[!] Warning: No MIDI control has been assigned to BUTTON_RIGHT_MIDI
BUTTON_ENTER_MIDI = None
[!] Warning: No MIDI control has been assigned to BUTTON_ENTER_MIDI
BUTTON_CANCEL_MIDI = None
[!] Warning: No MIDI control has been assigned to BUTTON_CANCEL_MIDI
BUTTON_LEFT_GPIO = 27
BUTTON_RIGHT_GPIO = 23
BUTTON_ENTER_GPIO = 17
BUTTON_CANCEL_GPIO = 24
BUTTON_UP_MIDI = None
[!] Warning: No MIDI control has been assigned to BUTTON_UP_MIDI
BUTTON_DOWN_MIDI = None
[!] Warning: No MIDI control has been assigned to BUTTON_DOWN_MIDI
BUTTON_FUNC_MIDI = None
[!] Warning: No MIDI control has been assigned to BUTTON_FUNC_MIDI
BUTTON_UP_GPIO = 23
BUTTON_DOWN_GPIO = 27
BUTTON_FUNC_GPIO = 17

END CONFIG IMPORT

midimaps.pkl <--- MIDI maps path


/SAMPLES/ HAS BEEN GROWN AND FORMATTED - READY TO GO


START SETLIST

SETLIST: No missing folders detected
SETLIST: No new folders found -> do nothing

END SETLIST

-= Preset world =-

START OF AUDIO DEVICES

Available devices:
0 audiocodec: - (hw:0,0), ALSA (2 in, 2 out)
1 snddaudio: - (hw:1,0), ALSA (2 in, 2 out)
2 sndhdmi: - (hw:2,0), ALSA (2 in, 8 out)
3 sysdefault, ALSA (128 in, 128 out)
4 dmix, ALSA (0 in, 2 out)

  • 5 default, ALSA (2 in, 2 out)
    6 /dev/dsp, OSS (16 in, 16 out)
    7 /dev/dsp1, OSS (16 in, 16 out)
    Exception in thread Thread-1:
    Traceback (most recent call last):
    File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
    File "/usr/lib/python2.7/threading.py", line 754, in run
    self.target(*self.args, **self.__kwargs)
    File "/home/sss/Alex/SamplerBox/modules/HD44780_sys_1.py", line 96, in lcd_main
    while self.loop_alive:
    AttributeError: LCD_SYS_1 instance has no attribute 'loop_alive'
    8 /dev/dsp2, OSS (16 in, 16 out)

Using user-defined AUDIO_DEVICE_ID (1)
Invalid audio device #1

END OF AUDIO DEVICES

INIT LOAD TIME: 4 seconds (before sample loading)


                                 SAW                                      

RAM check at START of preset load
CAN WE LOAD THE NEXT PRESET [SAW]?
Sample-set size : 0.13MB | Available RAM : 168.54MB
RAM usage : 30% | RAM limit : 65%

  • RAM usage is OK - can load next preset
    (time it took to return these figures: 0.004470s)

Current preset: [0: Saw]
RAM: no more RAM to free up

Preset [0: Saw]
x Samples are not loaded! Loading now...
x Notes are not filled! Filling now...
END LOADING: [0] Saw
///// All presets are now loaded into memory /////

Global keyword found in definition -> %%fillnotes=Y
RAM check at END of preset load
CAN WE LOAD THE NEXT PRESET [SAW]?
Sample-set size : 0.13MB | Available RAM : 167.07MB
RAM usage : 30% | RAM limit : 65%

  • RAM usage is OK - can load next preset
    (time it took to return these figures: 0.009720s)
    ^C
    Stopped by CTRL-C

root@orangepizero:~/Alex/SamplerBox#

S
Serj posted Nov 27, 20:42:

Ok, it's playing!
In config.ini need add LATENCY = low.

But latency not very good - from 15ms to 25ms. How can I reduce latency?

A
AlexM posted Nov 28, 01:58:

Can you try amending the AUDIO_DEVICE_NAME line to = /dev/dsp, OSS (and any of the other device names under "Available devices")

S
Serj posted Nov 28, 14:08:

Hi, Alex!
Works only with "/dev/dsp1, OSS" and "default ALSA", but nothing change.
Alex, I try yours fork and Joseph's fork. In Joseph's fork latency from 10 to 15 ms. In yours fork the latency now from 15 to 25 ms and strange decrease with next note until latency stay minimal 15 ms. After that the latency stay 25 ms and will decrease.
I send notes with Arduino on serial port OPI thru 1 second and tests signals with oscilloscope.

A
AlexM posted Nov 30, 06:02:

Hey Serj,

Are you able to try a USB MIDI keyboard to rule out the Arduino being a contributing factor?

What's the latency if you use the RPi's on-board audio?

It's a peculiar problem, especially seeing that the latency goes up to 25ms and then decreases. I'm a bit out of ideas at the moment - perhaps someone else has an idea.

FYI SamplerBox uses sounddevice - there ~may~ be a solution in the docs somewhere https://python-sounddevice.readthedocs.io/en/0.3.9/

S
Serj posted Dec 1, 13:50:

Hi, Alex!
Alex, please write a simple example. I'll send a midi command "NoteOn" to the serial port using Arduino, and you turn on the LED on any pin and play any test WAV-file. I will fix the result with an oscilloscope and we will see where the greatest delay occurs. Use the same libraries and modules that are used in SampleBox.

S
Serj posted yesterday, 19:25:

Hi, Alex!
I set blocksize=0 in sounddevice.Stream and now latency 7-11mc. Thank you for great job!

...

  (not published)
  I want to post as guest
 

Post