Skip to content

Commit def1f32

Browse files
committed
Merge branch 'up/feat/microphone-tester' into chore/all-my-stuffs
2 parents 0d18e6c + 05c51e5 commit def1f32

File tree

10 files changed

+266
-4
lines changed

10 files changed

+266
-4
lines changed

locales/de.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ tools:
282282
mime-types:
283283
title: MIME-Typen
284284
description: Konvertiere MIME-Typen in Erweiterungen und umgekehrt.
285+
mic-tester:
286+
title: Mikrofonprufung
287+
description: Wiedergabe und Visualisierung des Tons von Ihrem Mikrofon, mit einer Sekunde Verzögerung hinzugefügt
288+
start-button-text: Mikrofon-Wiedergabe Starten
289+
stop-button-text: Mikrofon-Wiedergabe Stoppen
285290
toml-to-json:
286291
title: TOML zu JSON
287292
description: Parse und konvertiere TOML zu JSON.

locales/en.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ tools:
253253
title: MIME types
254254
description: Convert MIME types to file extensions and vice-versa.
255255

256+
mic-tester:
257+
title: Microphone Tester
258+
description: Replay and Visualize sound from Your microphone, with added one second of delay
259+
start-button-text: Start replaying microphone
260+
stop-button-text: Stop replaying microphone
261+
256262
toml-to-json:
257263
title: TOML to JSON
258264
description: Parse and convert TOML to JSON.

locales/pl.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
home:
2+
categories:
3+
newestTools: 'Najnowsze narzędzia'
4+
favoriteTools: 'Twoje ulubione narzędzia'
5+
allTools: 'Wszystkie narzędzia'
6+
subtitle: 'Narzędzia dla programistów'
7+
toggleMenu: 'Menu'
8+
home: Strona główna
9+
uiLib: 'UI Lib'
10+
buyMeACoffee: 'Wesprzyj IT-Tools'
11+
follow:
12+
title: 'Podoba Ci się it-tools?'
13+
p1: 'Wesprzyj nas gwiazdką na'
14+
githubRepository: "repozytorium GitHub IT-Tools"
15+
p2: 'lub śledź nas na'
16+
twitterAccount: "koncie Twitter IT-Tools"
17+
thankYou: 'Dziękujemy!'
18+
nav:
19+
github: 'Repozytorium GitHub'
20+
githubRepository: "Repozytorium GitHub IT-Tools"
21+
twitter: 'Konto Twitter'
22+
twitterAccount: "Konto Twitter IT-Tools"
23+
about: "O IT-Tools"
24+
aboutLabel: 'O nas'
25+
darkMode: 'Tryb ciemny'
26+
lightMode: 'Tryb jasny'
27+
mode: 'Przełącz tryb ciemny/jasny'
28+
about:
29+
content: >
30+
# O IT-Tools
31+
32+
Ta wspaniała strona, stworzona z ❤ przez [Corentina Thomasseta](https://corentin.tech?utm_source=it-tools&utm_medium=about), zbiera przydatne narzędzia dla programistów i osób pracujących w IT. Jeśli uznasz ją za pomocną, nie zapomnij się nią podzielić i dodać do ulubionych!
33+
34+
IT Tools jest open-source (na licencji MIT) i darmowe, i takie pozostanie, ale koszty związane z jego hostingiem i odnawianiem domeny spoczywają na mnie. Jeśli chcesz wesprzeć moją pracę i zmotywować mnie do dodania kolejnych narzędzi, zachęcam do [wsparcia](https://www.buymeacoffee.com/cthmsst).
35+
36+
## Technologie
37+
38+
IT Tools zostało stworzone w Vue.js (Vue 3) z wykorzystaniem biblioteki komponentów Naive UI i jest hostowane oraz ciągle wdrażane przez Vercel. Niektóre narzędzia korzystają z zewnętrznych bibliotek open-source, pełną listę znajdziesz w pliku [package.json](https://github.com/CorentinTh/it-tools/blob/main/package.json) repozytorium.
39+
40+
## Znalazłeś błąd? Brakuje jakiegoś narzędzia?
41+
42+
Jeśli potrzebujesz narzędzia, które nie jest jeszcze dostępne, a uważasz, że mogłoby być przydatne, zapraszam do zgłoszenia propozycji funkcji w [sekcji issue](https://github.com/CorentinTh/it-tools/issues/new/choose) repozytorium GitHub.
43+
44+
404:
45+
notFound: '404 Nie znaleziono'
46+
sorry: "Przepraszamy, ta strona nie istnieje"
47+
maybe: 'Może to problem z cachem, spróbuj wymusić odświeżenie?'
48+
backHome: "Powrót na stronę główną"
49+
toolCard:
50+
new: Nowe
51+
search:
52+
label: Szukaj
53+
tools:
54+
categories:
55+
favorite-tools: 'Twoje ulubione narzędzia'
56+
crypto: Kryptografia
57+
converter: Konwerter
58+
web: Web
59+
images and videos: 'Obrazy i wideo'
60+
development: Programowanie
61+
network: Sieć
62+
math: Matematyka
63+
measurement: Pomiary
64+
text: Tekst
65+
data: Dane
66+
67+
token-generator:
68+
title: Generator tokenów
69+
description: >-
70+
Generuje losowy ciąg znaków z wybranych przez Ciebie znaków: wielkie
71+
lub małe litery, cyfry i/lub symbole.
72+
uppercase: Wielkie litery (ABC...)
73+
lowercase: Małe litery (abc...)
74+
numbers: Cyfry (123...)
75+
symbols: Symbole (!-;...)
76+
button:
77+
copy: Kopiuj
78+
refresh: Odśwież
79+
copied: Token został skopiowany
80+
length: Długość
81+
tokenPlaceholder: Token...
82+
83+
mic-tester:
84+
title: Tester mikrofonu
85+
description: Odtwórz i wizualizuj dźwięk z Twojego mikrofonu, z dodaną jedną sekundą opóźnienia
86+
start-button-text: Odtwarzaj mikrofonu
87+
stop-button-text: Zatrzymaj odtwarzanie mikrofonu

src/modules/i18n/components/locale-selector.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const localesLong: Record<string, string> = {
77
es: 'Español',
88
fr: 'Français',
99
no: 'Norwegian',
10+
pl: 'Polski',
1011
pt: 'Português',
1112
ru: 'Русский',
1213
uk: 'Українська',

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ import { tool as ipCidrToRange } from './ip-cidr-to-range';
248248
import { tool as ipRangeToCidr } from './ip-range-to-cidr';
249249
import { tool as ipv6AddressConverter } from './ipv6-address-converter';
250250
import { tool as jsonToObject } from './json-to-object';
251+
import { tool as micTester } from './mic-tester';
251252

252253
export const toolsByCategory: ToolCategory[] = [
253254
{
@@ -362,6 +363,7 @@ export const toolsByCategory: ToolCategory[] = [
362363
jsonDiff,
363364
softwareLicenceCompatibility,
364365
safelinkDecoder,
366+
micTester,
365367
snowflakeIdExtractor,
366368
apiTester,
367369
bounceParser,

src/tools/mic-tester/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Microphone } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
import { translate } from '@/plugins/i18n.plugin';
4+
5+
export const tool = defineTool({
6+
name: translate('tools.mic-tester.title'),
7+
path: '/mic-tester',
8+
description: translate('tools.mic-tester.description'),
9+
keywords: ['mic', 'microphone', 'test', 'check', 'troubleshoot', 'sound'],
10+
component: () => import('./mic-tester.vue'),
11+
icon: Microphone,
12+
});
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { onBeforeUnmount, ref } from 'vue';
2+
3+
interface IMessageSender {
4+
error: (...messages: any[]) => void
5+
}
6+
7+
export function useMicrophoneService(messageSender: IMessageSender) {
8+
let audioContext: AudioContext | null = null;
9+
let delayNode: DelayNode | null = null;
10+
let sourceNode: MediaStreamAudioSourceNode | null = null;
11+
let analyserNode: AnalyserNode | null = null;
12+
let stream: MediaStream | null = null;
13+
14+
const isPlaying = ref(false);
15+
const loudnessLevel = ref(0); // Observable for loudness
16+
17+
// Measure loudness and update loudness bar
18+
function measureLoudness() {
19+
const dataArray = new Uint8Array(analyserNode!.frequencyBinCount);
20+
21+
const updateLoudness = () => {
22+
analyserNode!.getByteFrequencyData(dataArray);
23+
24+
// Calculate average loudness
25+
let sum = 0;
26+
dataArray.forEach(value => sum += value);
27+
const average = sum / dataArray.length;
28+
29+
// Update the observable loudness level
30+
loudnessLevel.value = average;
31+
32+
if (isPlaying.value) {
33+
requestAnimationFrame(updateLoudness);
34+
}
35+
};
36+
updateLoudness();
37+
};
38+
39+
const startMicReplay = async () => {
40+
if (!audioContext) {
41+
audioContext = new (window.AudioContext || (window as any).webkitAudioContext)();
42+
}
43+
44+
try {
45+
stream = await navigator.mediaDevices.getUserMedia({ audio: true });
46+
}
47+
catch (err) {
48+
console.error('Microphone access denied:', err);
49+
messageSender.error('Microphone access denied (the error is also in the console):', err);
50+
return;
51+
}
52+
53+
sourceNode = audioContext.createMediaStreamSource(stream);
54+
delayNode = audioContext.createDelay(1.0);
55+
delayNode.delayTime.value = 1.0;
56+
57+
analyserNode = audioContext.createAnalyser();
58+
analyserNode.fftSize = 256;
59+
60+
// Connect nodes: mic -> delay -> speakers
61+
sourceNode.connect(delayNode);
62+
delayNode.connect(audioContext.destination);
63+
sourceNode.connect(analyserNode);
64+
65+
isPlaying.value = true;
66+
measureLoudness();
67+
};
68+
69+
function stopMicReplay() {
70+
if (audioContext && stream) {
71+
const tracks = stream.getTracks();
72+
tracks.forEach(track => track.stop());
73+
audioContext.close();
74+
audioContext = null;
75+
isPlaying.value = false;
76+
loudnessLevel.value = 0;
77+
}
78+
};
79+
80+
// Cleanup on service destruction
81+
onBeforeUnmount(() => {
82+
stopMicReplay();
83+
});
84+
85+
return {
86+
startMicReplay,
87+
stopMicReplay,
88+
loudnessLevel,
89+
isPlaying,
90+
};
91+
}

src/tools/mic-tester/mic-tester.vue

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<script setup lang="ts">
2+
import { useI18n } from 'vue-i18n';
3+
import { useMessage } from 'naive-ui';
4+
import { useMicrophoneService } from './mic-tester.service';
5+
6+
const message = useMessage();
7+
8+
const { t } = useI18n();
9+
const { startMicReplay, stopMicReplay, loudnessLevel, isPlaying } = useMicrophoneService(message);
10+
</script>
11+
12+
<template>
13+
<div>
14+
<c-card>
15+
<div class="control-buttons">
16+
<c-button :disabled="isPlaying" @click="startMicReplay">
17+
{{ t('tools.mic-tester.start-button-text') }}
18+
</c-button>
19+
<c-button :disabled="!isPlaying" @click="stopMicReplay">
20+
{{ t('tools.mic-tester.stop-button-text') }}
21+
</c-button>
22+
</div>
23+
24+
<!-- Loudness Meter -->
25+
<div id="loudnessMeter">
26+
<div id="loudnessBar" :style="{ width: `${loudnessLevel}%` }" />
27+
</div>
28+
</c-card>
29+
</div>
30+
</template>
31+
32+
<style scoped>
33+
#loudnessMeter {
34+
width: 100%;
35+
height: 30px;
36+
background-color: rgba(46, 51, 56, 0.05);
37+
margin-top: 20px;
38+
position: relative;
39+
}
40+
#loudnessBar {
41+
height: 100%;
42+
background: linear-gradient(48deg, rgba(37, 99, 108, 1) 0%, rgba(59, 149, 111, 1) 60%, rgba(20, 160, 88, 1) 100%);
43+
}
44+
.control-buttons {
45+
display: flex;
46+
gap: 10px;
47+
margin-bottom: 20px;
48+
justify-content: space-between;
49+
}
50+
</style>

src/tools/text-to-binary/text-to-binary.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ const { copy: copyText } = useCopy({ source: textFromBinary });
4242
test-id="text-to-binary-output"
4343
/>
4444
<div mt-2 flex justify-center>
45-
<c-button :disabled="!binaryFromText" @click="copyBinary()"> Copy binary to clipboard </c-button>
45+
<c-button :disabled="!binaryFromText" @click="copyBinary()">
46+
Copy binary to clipboard
47+
</c-button>
4648
</div>
4749
</c-card>
4850

@@ -68,7 +70,9 @@ const { copy: copyText } = useCopy({ source: textFromBinary });
6870
test-id="binary-to-text-output"
6971
/>
7072
<div mt-2 flex justify-center>
71-
<c-button :disabled="!textFromBinary" @click="copyText()"> Copy text to clipboard </c-button>
73+
<c-button :disabled="!textFromBinary" @click="copyText()">
74+
Copy text to clipboard
75+
</c-button>
7276
</div>
7377
</c-card>
7478
</template>

src/tools/text-to-unicode/text-to-unicode.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ const { copy: copyText } = useCopy({ source: textFromUnicode });
5757
</n-form-item>
5858
</div>
5959
<div mt-2 flex justify-center>
60-
<c-button :disabled="!unicodeFromText" @click="copyUnicode()"> Copy unicode to clipboard </c-button>
60+
<c-button :disabled="!unicodeFromText" @click="copyUnicode()">
61+
Copy unicode to clipboard
62+
</c-button>
6163
</div>
6264
</c-card>
6365
<c-card class="card" title="Unicode to Text">
@@ -81,7 +83,9 @@ const { copy: copyText } = useCopy({ source: textFromUnicode });
8183
test-id="unicode-to-text-output"
8284
/>
8385
<div mt-2 flex justify-center>
84-
<c-button :disabled="!textFromUnicode" @click="copyText()"> Copy text to clipboard </c-button>
86+
<c-button :disabled="!textFromUnicode" @click="copyText()">
87+
Copy text to clipboard
88+
</c-button>
8589
</div>
8690
</c-card>
8791
</div>

0 commit comments

Comments
 (0)