Example of Recording from the Mic and processing the (PCM?) file - ios

I need to record sounds from the iPhone mic and process the samples in my Swift app. I would really appreciate an example to follow.
These Recording settings
let recordSettings:[String : AnyObject] = [
AVFormatIDKey: NSNumber(unsignedInt:kAudioFormatLinearPCM),
//AVEncoderAudioQualityKey : AVAudioQuality.Max.rawValue,
// AVEncoderBitRateKey : 320000,
AVNumberOfChannelsKey: 1,
AVSampleRateKey : 8000.0,
AVLinearPCMBitDepthKey: 16,
AVLinearPCMIsBigEndianKey: "true",
AVLinearPCMIsFloatKey: "false"
]
produce the following bytes
99 97 102 102 0 1 0 0 100 101 115 99 0 0 0 0 0 0 0 32 64 191 64 0 0 0 0 0 108 112 99 109 0 0 0 2 0 0 0 2 0 0 0 1 0 0 0 1 0 0 0 16 102 114 101 101 0 0 0 0 0 0 15 176 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Which looks fishy maybe it's a double still?

I already created an example for something like that. It gets the data from the microphone, does a Fast-Fourier-Transform on it to find the frequencies and displays them in the view. It's done for OSX, but it should also work on iOS:
https://github.com/Kametrixom/Frequencies

Related

Find specific value in file using lua

i have file with below format :-
** Resuming transfer from byte position 13247324
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:08 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:09 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:09 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:10 --:--:-- 0
0 9539k 0 0 0 0 0 0 --:--:-- 0:00:11 --:--:-- 0
0 9539k 0 0 0 0 0 0 --:--:-- 0:00:12 --:--:-- 0
0 9539k 0 8192 0 0 598 0 4:32:14 0:00:13 4:32:01 1882
0 9539k 0 13238 0 0 865 0 3:08:12 0:00:15 3:07:57 2459
39k 11 1109k 0 0 12684 0 0:12:50 0:01:29 0:11:21 22753
11 9539k 11 1117k 0 0 12570 0 0:12:57 0:01:31 0:11:26 15004
11 9539k 11 1117k 0 0 12433 0 0:13:05 0:01:32 0:11:33 11847
11 9539k 11 1117k 0 0 12299 0 0:13:14 0:01:33 0:11:41 9191
11 9539k 11 1117k 0 0 12168 0 0:13:22 0:01:34 0:11:48 6011
11 9539k 11 1124k 0 0 12122 0 0:13:25 0:01:35 0:11:50 2844
12 9539k 12 1173k 0 0 12566 0 0:12:57 0:01:35 0:11:22 12479
12 9539k 12 1173k 0 0 12384 0 0:13:08 0:01:37 0:11:31 11475
12 9539k 12 1173k 0 0 12257 0 0:13:16 0:01:38 0:11:38 11473
12 9539k 12 1197k 0 0 12371 0 0:13:09 0:01:39 0:11:30 16129
I want to find only the average dload values
My current code is :-
local file = io.open(path, "rb")
if not file then return nil end
local lines = {}
local words = {}
for line in io.lines(path) do
for word in line:gmatch("%w+") do
table.insert(words, word)
end
table.insert(lines, words)
end
file:close()
return words;
But this code is giving me indexes , and all words as values. I am not able to find specific value for average dload
I am new to lua , any help is much appreciated
I think you are almost there. This is how I would do that. col will hold the number of the column for which we are gathering the output, such that you can separately get the stats for the different columns.
local file = io.open(path, "rb")
if not file then return nil end
local lines = {}
local stats = {}
local col
for line in io.lines(path) do
col = 0
for word in line:gmatch("%w+") do
if word then
col = col + 1
stats[col] = stats[col] or { }
stats[col][word] = (stats[col][word] or 0) + 1
end
end
table.insert(lines, words)
end
file:close()
When I do now the following:
for col, val in ipairs(stats) do
for word, count in pairs(val) do
print("Col=", col, "word=", word, "count=",count)
end
end
I get the following output:
Col= 1 word= 39k count= 1
Col= 1 word= 0 count= 13
Col= 1 word= 11 count= 5
Col= 1 word= 12 count= 4
Col= 2 word= 0 count= 9
Col= 2 word= 9539k count= 13
Col= 2 word= 11 count= 1
Col= 3 word= 12 count= 4
...etc.

What does the "*A" and "*U" means in the "sctp assocs" display?

cat /proc/net/sctp/assocs
ASSOC-ID ASSOC SOCK STY SST ST HBKT TX_QUEUE RX_QUEUE UID INODE LPORT RPORT LADDRS <-> RADDRS HBINT INS OUTS MAXRT T1X T2X RTXC wmema wmemq sndbuf rcvbuf
13 ffff8800b93a9000 ffff8800ac752300 2 1 3 9176 0 0 0 20735 3905 48538 *192.168.44.228 <-> *A172.16.236.92 7500 10 10 2 0 0 23 1 0 2000000 2000000
0 ffff88042aea3000 ffff880422e88000 0 10 1 40840 0 0 0 9542 3868 3868 *10.127.58.66 <-> *U10.127.115.194 7500 17 17 10 0 0 0 1 0 8388608 8388608

Erlang application exit,, but vm is still running

My Erlang applicaation processed crashed and then exited, but found that the erlang VM is still running.
I could recieve pong when ping this "suspended node"
Types regs() and the results show below, there is not my app process.
(hub#192.168.1.140)4> regs().
** Registered procs on node 'hub#192.168.1.140' **
Name Pid Initial Call Reds Msgs
application_controlle <0.7.0> erlang:apply/2 30258442 1390
auth <0.20.0> auth:init/1 189 0
code_server <0.26.0> erlang:apply/2 1194028 0
erl_epmd <0.19.0> erl_epmd:init/1 138 0
erl_prim_loader <0.3.0> erlang:apply/2 2914236 0
error_logger <0.6.0> gen_event:init_it/6 49983527 0
file_server_2 <0.25.0> file_server:init/1 16185407 0
global_group <0.24.0> global_group:init/1 107 0
global_name_server <0.13.0> global:init/1 1385 0
gr_counter_sup <0.43.0> supervisor:gr_counter_sup 253 0
gr_lager_default_trac <0.70.0> gr_counter:init/1 121 0
gr_lager_default_trac <0.72.0> gr_manager:init/1 46 0
gr_lager_default_trac <0.69.0> gr_param:init/1 117 0
gr_lager_default_trac <0.71.0> gr_manager:init/1 46 0
gr_manager_sup <0.45.0> supervisor:gr_manager_sup 484 0
gr_param_sup <0.44.0> supervisor:gr_param_sup/1 253 0
gr_sup <0.42.0> supervisor:gr_sup/1 237 0
inet_db <0.16.0> inet_db:init/1 749 0
inet_gethost_native <0.176.0> inet_gethost_native:serve 4698517 0
inet_gethost_native_s <0.175.0> supervisor_bridge:inet_ge 41 0
init <0.0.0> otp_ring0:start/2 30799457 0
kernel_safe_sup <0.35.0> supervisor:kernel/1 278 0
kernel_sup <0.11.0> supervisor:kernel/1 47618 0
lager_crash_log <0.52.0> lager_crash_log:init/1 97712230 0
lager_event <0.50.0> gen_event:init_it/6 1813660437 0
lager_handler_watcher <0.51.0> supervisor:lager_handler_ 358 0
lager_sup <0.49.0> supervisor:lager_sup/1 327 0
net_kernel <0.21.0> net_kernel:init/1 110769667 0
net_sup <0.18.0> supervisor:erl_distributi 313 0
os_cmd_port_creator <0.582.0> erlang:apply/2 81 0
rex <0.12.0> rpc:init/1 15653480 0
standard_error <0.28.0> erlang:apply/2 9 0
standard_error_sup <0.27.0> supervisor_bridge:standar 41 0
timer_server <0.100.0> timer:init/1 59356077 0
user <0.31.0> group:server/3 23837008 0
user_drv <0.30.0> user_drv:server/2 12239455 0
** Registered ports on node 'hub#192.168.1.140' **
Name Id Command
ok
It rarely occurs, but anyone explains it?
System: CentOS 5.8
Erlang: R15B03

Why this parameter '+profile "*"' get convert killed?

If I run this command,
convert -limit memory 2071963648 -quality 100 -alpha off -density 165% -scene 1 infile.jpg outfile.png
The conversion runs without any issue.
However if I add +profile "*",
convert +profile "*" -limit memory 2071963648 -quality 100 -alpha off -density 165% -scene 1 infile.jpg outfile.png
The process is killed.
Here is output from dmesg
[ 1403.401440] [ pid ] uid tgid total_vm rss nr_ptes swapents oom_score_adj name
[ 1403.401444] [ 474] 0 474 4869 49 13 0 0 upstart-udev-br
[ 1403.401446] [ 480] 0 480 12460 207 27 0 -1000 systemd-udevd
[ 1403.401448] [ 659] 0 659 3815 55 13 0 0 upstart-socket-
[ 1403.401449] [ 671] 0 671 2556 572 8 0 0 dhclient
[ 1403.401451] [ 852] 102 852 9806 94 23 0 0 dbus-daemon
[ 1403.401453] [ 860] 101 860 65019 147 29 0 0 rsyslogd
[ 1403.401454] [ 884] 0 884 10863 85 27 0 0 systemd-logind
[ 1403.401456] [ 888] 0 888 3819 64 11 0 0 upstart-file-br
[ 1403.401463] [ 967] 0 967 3635 41 12 0 0 getty
[ 1403.401464] [ 970] 0 970 3635 42 12 0 0 getty
[ 1403.401466] [ 974] 0 974 3635 40 12 0 0 getty
[ 1403.401467] [ 975] 0 975 3635 40 12 0 0 getty
[ 1403.401468] [ 977] 0 977 3635 41 12 0 0 getty
[ 1403.401470] [ 1047] 0 1047 15341 169 33 0 -1000 sshd
[ 1403.401472] [ 1052] 0 1052 5914 58 17 0 0 cron
[ 1403.401473] [ 1057] 0 1057 4785 40 13 0 0 atd
[ 1403.401475] [ 1089] 0 1089 1092 36 8 0 0 acpid
[ 1403.401476] [ 1099] 0 1099 4797 63 15 0 0 irqbalance
[ 1403.401478] [ 1224] 0 1224 6336 78 16 0 0 master
[ 1403.401479] [ 1230] 106 1230 6852 73 18 0 0 pickup
[ 1403.401481] [ 1231] 106 1231 6893 81 19 0 0 qmgr
[ 1403.401482] [ 1281] 999 1281 278175 5269 82 0 0 sensu-client
[ 1403.401484] [ 1397] 0 1397 3635 42 11 0 0 getty
[ 1403.401485] [ 1398] 0 1398 3197 37 11 0 0 getty
[ 1403.401487] [ 1515] 107 1515 7862 150 19 0 0 ntpd
[ 1403.401488] [ 1929] 0 1929 26408 247 55 0 0 sshd
[ 1403.401490] [ 1982] 1000 1982 26442 256 53 0 0 sshd
[ 1403.401491] [ 1983] 1000 1983 5580 761 16 0 0 bash
[ 1403.401493] [ 2488] 1000 2488 8685 1607 22 0 0 pynt
[ 1403.401494] [ 2490] 1000 2490 8685 1607 21 0 0 pynt
[ 1403.401495] [ 2491] 1000 2491 1111 24 7 0 0 sh
[ 1403.401497] [ 2492] 1000 2492 1111 25 7 0 0 sh
[ 1403.401498] [ 2493] 1000 2493 15638 3221 36 0 0 python
[ 1403.401500] [ 2494] 1000 2494 15939 3535 36 0 0 python
[ 1403.401501] [ 2924] 1000 2924 975967 954941 1894 0 0 convert
[ 1403.401503] Out of memory: Kill process 2924 (convert) score 945 or sacrifice child
[ 1403.406111] Killed process 2924 (convert) total-vm:3903868kB, anon-rss:3819760kB, file-rss:4kB
I am using this version of ImageMagick
$ convert -version
Version: ImageMagick 6.8.9-7 Q16 x86_64 2014-12-30 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: jng jpeg png x xml zlib
on ubuntu 14.04.1
I don't know why +profile would cause ImageMagick to crash, but as an alternative you might like to try -strip like this.
convert image.jpg -strip output.jpg
It strips the image of all profiles and comments.

puppettop? How can I see what puppet is doing?

I'm getting started with Puppet. I added some lines to a manifest and when running Puppet now it's been at 100% cpu for a very longtime. Is there a good way to see what puppet is actually doing? puppettop?
top gives me this, which is quite useless:
top - 20:02:11 up 1 day, 2:30, 5 users, load average: 1.02, 1.12, 0.93
Tasks: 164 total, 2 running, 162 sleeping, 0 stopped, 0 zombie
Cpu(s): 12.5%us, 0.0%sy, 0.0%ni, 87.4%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 32809072k total, 10412396k used, 22396676k free, 243832k buffers
Swap: 16768892k total, 0k used, 16768892k free, 6978500k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
9761 root 20 0 646m 558m 3568 R 100 1.7 20:42.88 puppet
10509 guaka 20 0 17344 1352 972 R 0 0.0 0:00.28 top
1 root 20 0 24216 2192 1344 S 0 0.0 0:00.85 init
2 root 20 0 0 0 0 S 0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0 0.0 0:02.83 ksoftirqd/0
4 root 20 0 0 0 0 S 0 0.0 0:00.00 kworker/0:0
5 root 0 -20 0 0 0 S 0 0.0 0:00.00 kworker/0:0H

Resources