linux 에서는 pulseaudio 쓰는 라이브러리가 유리하겠지?

[링크 : https://pypi.org/project/SoundCard/]

[링크 : https://soundcard.readthedocs.io/en/latest/]

 

Posted by 구차니

chatGPT 님 가라사대

재생 예제, 녹음 + fft 분석

import numpy as np
import sounddevice as sd

# 파라미터 설정
duration = 3  # 재생할 시간(초)
sampling_freq = 44100  # 샘플링 주파수 (Hz)
frequency = 440  # sine 파의 주파수 (Hz)

# 시간 배열 생성
t = np.linspace(0, duration, int(sampling_freq * duration), endpoint=False)

# sine 파 생성
sine_wave = np.sin(2 * np.pi * frequency * t)

# 사운드 재생
sd.play(sine_wave, samplerate=sampling_freq)
sd.wait()  # 재생이 끝날 때까지 대기
import numpy as np
import matplotlib.pyplot as plt
import sounddevice as sd
from scipy.fft import fft

# 녹음 파라미터 설정
duration = 5  # 녹음 시간 (초)
sampling_freq = 44100  # 샘플링 주파수 (Hz)

# 녹음 시작
print("녹음을 시작합니다...")
recorded_audio = sd.rec(int(duration * sampling_freq), samplerate=sampling_freq, channels=1)
sd.wait()  # 녹음이 끝날 때까지 대기
print("녹음이 완료되었습니다.")

# FFT를 위한 주파수 영역 생성
freq_axis = np.fft.fftfreq(len(recorded_audio), d=1/sampling_freq)

# FFT 계산
audio_fft = fft(recorded_audio.flatten())

# FFT 결과 그래프 표시
plt.figure(figsize=(10, 4))
plt.plot(freq_axis[:len(freq_axis)//2], np.abs(audio_fft)[:len(freq_axis)//2])
plt.title("FFT 분석 결과")
plt.xlabel("주파수 (Hz)")
plt.ylabel("Magnitude")
plt.grid(True)
plt.show()

[링크 : https://pypi.org/project/sounddevice/]

 

Assuming you have a NumPy array named myarray holding audio data with a sampling frequency of fs (in the most cases this will be 44100 or 48000 frames per second), you can play it back with play():
sd.play(myarray, fs)

[링크 : https://python-sounddevice.readthedocs.io/en/0.4.6/usage.html#playback]

 

duration = 10.5  # seconds
myrecording = sd.rec(int(duration * fs), samplerate=fs, channels=2)

[링크 : https://python-sounddevice.readthedocs.io/en/0.4.6/usage.html#recording]

 

[링크 : https://python-sounddevice.readthedocs.io/en/0.4.6/]

 

+

반복 재생

import soundfile as sf
import sounddevice as sd

weight = 1.4

data, fs = sf.read('sound.wav')
sd.play(data * weight, fs,loop=True)
sd.stop()

[링크 : https://stackoverflow.com/questions/47606214/stop-the-loop-in-sounddevice-audio-output]

Posted by 구차니
Programming/vue.js2024. 5. 9. 10:21

created가 이름부터 당연하지만(?) mounted 보다 우선적으로 작동하고

mounted는 ui에 연결되는 변수에 대해서 초기화 하는 쪽

 

[링크 : https://ko.vuejs.org/guide/essentials/lifecycle]

    [링크 : https://webruden.tistory.com/926]

[링크 : https://aomee0880.tistory.com/185]

 

computed는 저장된 결과를 반환

method는 렌더링 시 마다 함수 실행

이라는데 무슨 뜻인지.. 종속된 값이 먼지 부터 찾아 봐야 할 듯.

[링크 : https://sunny921.github.io/posts/vuejs-computed-method/]

 

computed는 값이 변하는 이벤트가 발생하지 않으면 처리 조차 하지 않고 기존 값을 리턴(캐싱) 한다.

computed는 예제의 message의 값이 변했을 경우만 다시 렌더링 한다.

[링크 : https://kbcoding.tistory.com/47]

 

'Programming > vue.js' 카테고리의 다른 글

vue.js node.js 메모리 누수?  (0) 2024.04.22
vue webpack  (0) 2024.04.19
vue import "@"  (0) 2024.04.19
vue webpack ckeditor  (0) 2024.04.19
vue3 ckeditor5 document editor 추가하기  (0) 2024.04.18
Posted by 구차니

python 실행하기 위한 명령어 줄, 물론 pip 로 패키지도 없어서 그냥 깡통 python 상태

$ docker run --rm -it python python

[링크 : https://seorenn.github.io/note/docker-development-environment.html]

 

docker 로 장치연결해주기

docker run -ti -v /tmp/.X11-unix/:/tmp/.X11-unix --env QT_X11_NO_MITSHM=1 --device=/dev/video0:/dev/video0 -e DISPLAY=$DISPLAY --name test pytorch/pytorch:1.12.1-cuda11.3-cudnn8-devel /bin/bash

[링크 : https://shuka.tistory.com/68]

[링크 : https://blog.naver.com/cheeryun/222383212241]

 

$ docker run --rm -it python bash
# pip install opencv-python

[링크 : https://pypi.org/project/opencv-python/]

 

아래는 테스트 필요 + docker 내에서 해야하나 찾아보는 중

$ sudo apt install libgl1-mesa-glx libglib2.0-0

[링크 : https://yuevelyne.tistory.com/entry/OpenCV-ImportError-libGLso1-cannot-open-shared-object-file-No-such-file-or-directory]

 

wayland 예제 검색.. 

$ docker run -e XDG_RUNTIME_DIR=/tmp \
           -e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
           -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY  \
           --user=$(id -u):$(id -g) \
           imagename waylandapplication


[링크 : https://unix.stackexchange.com/questions/330366/]

 

ubuntu 22.04 인데 안된다. ㅠㅠ

Qt 쪽 변수를 넘겨줘야 하나?

>>> cv2.imshow("test",a)
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.12/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

Aborted (core dumped)

 

패키지 깐다고 해결되면 행복은 하겠는데...

pip install PyQt5

[링크 : https://csm-kr.tistory.com/114]

'Programming > python(파이썬)' 카테고리의 다른 글

python soundcard 라이브러리  (0) 2024.05.21
python 사운드 장치  (0) 2024.05.10
python thread event  (0) 2024.03.05
cv2.ximgproc 없을 경우  (0) 2024.02.28
cv2.stereoBM + WLS  (0) 2024.02.28
Posted by 구차니
Programming/vue.js2024. 4. 22. 17:35

vue에서 npm run server 하는데, 아래처럼 메시지가 나오고 멈춰있어서

[70%] sealing finish module graph ESLintWebpackPlugin_1

 

top 으로 보는데 node 가 32G의 메모리는 가상으로 잡고 있는걸 보고 기겁..

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                  
  61734 root      20   0   31.8g   1.0g  41728 R 100.0   6.7   3:02.32 node           

 

아무튼 가상메모리 관련해서 문제가 있는거 아닌가 해서 우회법을 찾는데 영.. 되질 않네

[링크 : https://divlook.tistory.com/10]

[링크 : https://evan-moon.github.io/2019/08/08/fix-webpack-dev-memory-leak/]

 

NODE_OPTIONS=--max-old-space-size=4096

Note
: If you have specified export NODE_OPTIONS=<value> in your package.json, it'll override what you set in the NODE_OPTIONS environment variable in the config.yml (either at the container, job, or step respective level)

[링크 : https://support.circleci.com/hc/en-us/articles/360009208393-How-Can-I-Increase-the-Max-Memory-for-Node]

'Programming > vue.js' 카테고리의 다른 글

vue created mounted, method computed  (0) 2024.05.09
vue webpack  (0) 2024.04.19
vue import "@"  (0) 2024.04.19
vue webpack ckeditor  (0) 2024.04.19
vue3 ckeditor5 document editor 추가하기  (0) 2024.04.18
Posted by 구차니
Programming/vue.js2024. 4. 19. 19:06

도대체 이 망할(?) webpack은 처음부터 되어있던거 아닌가?

ckeditor 넣어서 하려니 멀 어떻게 해야 할지 감이 안돈다.

 

[링크 : https://cli.vuejs.org/guide/webpack.html]

[링크 : https://reintech.io/blog/integrating-vue-js-with-webpack]

 

'Programming > vue.js' 카테고리의 다른 글

vue created mounted, method computed  (0) 2024.05.09
vue.js node.js 메모리 누수?  (0) 2024.04.22
vue import "@"  (0) 2024.04.19
vue webpack ckeditor  (0) 2024.04.19
vue3 ckeditor5 document editor 추가하기  (0) 2024.04.18
Posted by 구차니
Programming/vue.js2024. 4. 19. 18:07

node.js 에서 alias로 정의되는 소스 디렉토리의 경로

[링크 : https://mikkeller.tistory.com/26]

[링크 : https://stackoverflow.com/questions/42749973/what-does-the-mean-inside-an-import-path]

 

'Programming > vue.js' 카테고리의 다른 글

vue.js node.js 메모리 누수?  (0) 2024.04.22
vue webpack  (0) 2024.04.19
vue webpack ckeditor  (0) 2024.04.19
vue3 ckeditor5 document editor 추가하기  (0) 2024.04.18
vue 입력창 포커스 설정  (0) 2024.03.28
Posted by 구차니
Programming/vue.js2024. 4. 19. 15:36

기능 하나 추가하려니 -build- 라는걸 쓰니까, 이미 빌드된거라 다른걸 추가하면 충돌나면서

ckeditor-duplicated-modules 이런 에러가 발생한다.

 

해결하려면 online builder로 zip 파일을 받거나

vite나 webpack을 이용하여 원하는 플러그인을 추가한 다음 빌드해서 써야 하는 것으로 보인다.

[링크 : https://github.com/ckeditor/ckeditor5-vue/issues/215]

[링크 : https://ckeditor.com/docs/ckeditor5/latest/installation/integrations/vuejs-v3.html#webpack]

[링크 : https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/alternative-setups/integrating-from-source-webpack.html]

 

[링크 : https://2jun0.tistory.com/27]

'Programming > vue.js' 카테고리의 다른 글

vue webpack  (0) 2024.04.19
vue import "@"  (0) 2024.04.19
vue3 ckeditor5 document editor 추가하기  (0) 2024.04.18
vue 입력창 포커스 설정  (0) 2024.03.28
vue proxy  (0) 2024.03.26
Posted by 구차니

이전 예제는 모바일 크롬에서 안되서 다시 찾아봄

 

[링크 : https://github.com/LazarSoft/jsqrcode/tree/master/src]

'Programming > javascript & HTML' 카테고리의 다른 글

js DataView()  (0) 2024.08.21
javascript ... (rest parameter)  (0) 2024.08.12
QR decoder로 로또 추첨하기  (0) 2024.04.16
javascript 집합(set) 내용 출력하기  (0) 2024.04.16
js split()  (0) 2024.04.12
Posted by 구차니
Programming/android2024. 4. 19. 00:05

 

chrome://inspect/#devices

[링크 : https://hotel-iu.tistory.com/279]

 

오랫만에 해서 USB 디버깅 켜는 법도 까먹었네

빌드버전 열심히 누르면 디버깅 모드가 숨겨져 있다가 나타난다

[링크 : https://support.google.com/android/thread/231740096/관리자가-아닌-사용자-환경에서-개발자-모드-활성화-안됨?hl=ko]

 

핸드폰에서 왜 안되었나 했는데..

핸드폰이 느려서 읽는데 반응을 못해준거였냐 -_-

index.min.js:1 Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
o._createImageData @ index.min.js:1
o._decodeFromImageElm @ index.min.js:1
(anonymous) @ index.min.js:1
(anonymous) @ index.min.js:1
(anonymous) @ index.min.js:1
a @ index.min.js:1
o.decodeFromImage @ index.min.js:1
eval @ VM138:1
qr_decode @ lotto.html:38
await in qr_decode (async)
preview.onload @ lotto.html:62
load (async)
reader.onload @ lotto.html:61
load (async)
previewFile @ lotto.html:57
onchange @ lotto.html:12
Promise {: false}[[Prototype]]: Promise[[PromiseState]]: "fulfilled"[[PromiseResult]]: false

[링크 : https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently]

 

수정해 보았는데 영 안되네.. -_-

getContext('2d', { willReadFrequently: true });

[링크 : https://stackoverflow.com/questions/74020182/canvas2d-multiple-readback-operations-using-getimagedata-are-faster-with-the-wi]

'Programming > android' 카테고리의 다른 글

android hdmi rotate  (4) 2022.05.12
안드로이드 강제 종료  (0) 2022.03.11
안드로이드 앱 자동 실행 설정  (0) 2022.03.02
안드로이드 system.img 마운트 하기  (0) 2022.02.18
안드로이드 64bit 지원  (0) 2021.07.27
Posted by 구차니