summaryrefslogtreecommitdiff
path: root/speakerSqeaker.txt
blob: bb4e8a65cd9b4901b32d1787a276896acde153ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /bin/bash
# Workaround for stupd 'powersave' 'feature' of Creative Speakers
#
# SJP 11 Dec 2021
#
#  This is just a stub for now

# Which device is the audio output going to?

# st33v@cr4y:~$ grep RUNNING /proc/asound/card*/pcm*/sub*/status
# /proc/asound/card2/pcm0p/sub0/status:state: RUNNING

# That is fine, but the status remains as 'RUNNING' even after the speakers have turned themselves off...
# So I'm going down the track of periodically sending a 'sound' to a loopback device
# sudo modprobe snd-aloop
# Now aply -l shows a new 'card' called Loopback.


record one second of default stream:

$ rec -d  -n trim 0 1 stat

    rec       sox in record mode
    -d        default input
    -n        direct output to /dev/null
    trim 0 1  duration 1 second
    stat

Output:

Input File     : 'default' (pulseaudio)
Channels       : 2
Sample Rate    : 48000
Precision      : 16-bit
Sample Encoding: 16-bit Signed Integer PCM

In:0.00% 00:00:01.02 [00:00:00.00] Out:48.0k [      |      ]        Clip:0    
Samples read:             96000
Length (seconds):      1.000000
Scaled by:         2147483647.0
Maximum amplitude:     0.000000
Minimum amplitude:     0.000000
Midline amplitude:     0.000000
Mean    norm:          0.000000
Mean    amplitude:     0.000000
RMS     amplitude:     0.000000
Maximum delta:         0.000000
Minimum delta:         0.000000
Mean    delta:         0.000000
RMS     delta:         0.000000
Rough   frequency:  -2147483648
Done.

So if Max amplitude = 0 then we have silence!

to generate a tone that is not audible:
play -n  synth 1 sine  40 fade .2 0

  play    sox alias
  -n      dummy input file
  synth   synthesise a sound
  sine    sine wave [the default, so not strictly necessary]
  40      Hz
  fade    fade in from zero volume to max volume over 200 msec.
          '0' says fade out at end over same period.


Communicate with journald:
echo hello $USER | systemd-cat -t AlexySayle -p warning
    -t lable the source of the message
    -p priority level - affects colour in logfile. 
                        Alert creates a bell (hw speaker beep) (ASCII 0x07)
RED
Jan 27 13:07:40 cr4y Tui the Dog[5693]: Thu, 27 Jan 2022 13:07:40 +1100 woof woof alert
Jan 27 13:07:52 cr4y Tui the Dog[5697]: Thu, 27 Jan 2022 13:07:52 +1100 woof woof crit
Jan 27 13:08:02 cr4y Tui the Dog[5701]: Thu, 27 Jan 2022 13:08:02 +1100 woof woof err
Yellow, bold
Jan 27 13:08:14 cr4y Tui the Dog[5704]: Thu, 27 Jan 2022 13:08:14 +1100 woof woof warning
Green, bold
Jan 27 13:08:28 cr4y Tui the Dog[5707]: Thu, 27 Jan 2022 13:08:28 +1100 woof woof notice
Green (default)
Jan 27 13:08:40 cr4y Tui the Dog[5710]: Thu, 27 Jan 2022 13:08:40 +1100 woof woof info
Grey
Jan 27 13:08:50 cr4y Tui the Dog[5713]: Thu, 27 Jan 2022 13:08:50 +1100 woof woof debug