Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing digiducer 333D04 #3

Open
SebastianCarta opened this issue Jun 25, 2024 · 0 comments
Open

testing digiducer 333D04 #3

SebastianCarta opened this issue Jun 25, 2024 · 0 comments

Comments

@SebastianCarta
Copy link

Good morning,

i am testing the 333D04 and the code is not working, what could be the problem?
Befourf finding your code i was testing my code for simple data acquisition (no scaling) the sensor seems to connect as an external device. The problem is when i beng on the sensor there is no clues of the impact in the waveform data or in the recording.

Can somone halp me with that? i post you the code:

clear all
close all
clc

% Parametri di configurazione
sampleRate = 44100; % Frequenza di campionamento in Hz
samplesPerFrame = 44100; % Numero di campioni per frame
numChannels = 1; % Numero di canali (mono)
recordingTime = 10; % Durata della registrazione in secondi

% List all available audio devices
devices = getAudioDevices(audioDeviceReader);
disp('Available audio devices:');
disp(devices);

% Specifica il nome del dispositivo esterno (Update based on the listed devices)
externalDeviceName ='Microfono (333D04 10780870666313184230223)';

% Error handling for device setup
try
% Crea un oggetto audioDeviceReader per acquisire dati dalla scheda audio esterna
deviceReader = audioDeviceReader('SampleRate', sampleRate, ...
'SamplesPerFrame', samplesPerFrame, ...
'NumChannels', numChannels, ...
'Device', externalDeviceName);
catch ME
disp('Error creating audioDeviceReader:');
disp(ME.message);
return;
end

% Verifica la configurazione della scheda audio
deviceInfo = info(deviceReader);
disp(deviceInfo);

% Calcola il numero di frame necessari per la durata della registrazione
numFrames = round(recordingTime * sampleRate / samplesPerFrame);

% Prealloca l'array per memorizzare i dati acquisiti
audioData = zeros(numFrames * samplesPerFrame, numChannels);

disp('Inizio registrazione...')

% Acquisisci i dati audio in frame
for i = 1:numFrames
audioFrame = deviceReader();
audioData((i-1)samplesPerFrame+1:isamplesPerFrame, :) = audioFrame;
end

disp('Registrazione completata.')

% Rilascia la risorsa del dispositivo
release(deviceReader);

% Verifica la lunghezza dei dati acquisiti
disp(['Lunghezza dei dati acquisiti: ', num2str(length(audioData))]);

% Salva i dati acquisiti in un file audio (opzionale)
audiowrite('PROVA.wav', audioData, sampleRate);

% Riproduci i dati acquisiti (opzionale)
sound(audioData, sampleRate);

thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant