How to read an electric signal through sound card? (C++)

  • Context: C/C++ 
  • Thread starter Thread starter da_coolest
  • Start date Start date
  • Tags Tags
    Electric Signal Sound
Click For Summary

Discussion Overview

The discussion revolves around the feasibility and methods for reading an electric signal through a sound card, specifically for the purpose of capturing and analyzing ECG data using C++ on Windows. Participants explore various approaches, including the use of sound card inputs and multimedia libraries.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about using the sound card's jacks to capture amplified electric signals from the heart and seeks advice on methods for doing so with C++.
  • Another participant suggests that using a peripheral card to stream data directly from the medical device could be a viable option, but notes that the specifics depend on the device's nature and manufacturer.
  • There is mention of Windows libraries, specifically DirectSound, as a potential tool for capturing sound card data.
  • A participant describes their homemade device that amplifies signals through electrodes and expresses interest in connecting it to the sound card for data extraction to create an ECG diagram.
  • Discussion includes a proposed method for identifying local maximums in the captured signal data to determine heart pulses, although it is acknowledged as a simple approach.
  • Another participant requests suggestions for methods to capture signals that allow for analysis, noting that many multimedia libraries seem limited to recording or playback functionalities.
  • DirectSound is reiterated as a recommended option for interfacing with the sound card at a low level to obtain raw data.

Areas of Agreement / Disagreement

Participants express various viewpoints on the best methods to capture and analyze signals through the sound card, with no clear consensus on a single approach. Some suggest using DirectSound, while others consider alternative hardware solutions.

Contextual Notes

Participants acknowledge limitations in their knowledge about specific medical devices and the nature of the signals being captured, which may affect the applicability of their suggestions.

da_coolest
Messages
15
Reaction score
0
How to read a signal through the sound card? I want to capture an amplified electric signal that emerge in the heart, and then to draw the ECG diagram.

Can I use the soundcard's jacks for this purpose? if then, what is the best method to use to capture these signals using C++ on windows?

if using the sound card is not the best solution, what would you suggest?

Thanks in advance!
 
Technology news on Phys.org
da_coolest said:
How to read a signal through the sound card? I want to capture an amplified electric signal that emerge in the heart, and then to draw the ECG diagram.

Can I use the soundcard's jacks for this purpose? if then, what is the best method to use to capture these signals using C++ on windows?

if using the sound card is not the best solution, what would you suggest?

Thanks in advance!

Hey da_coolest and welcome to the forums.

For your second question, you may have a few options but if you can still a peripheral card that allows to stream the data straight from your medical device to the computer, then that will be a viable option.

Using the above device will depend on the nature of the device and who made it. For example you might get a device that comes with a complete software package and device driver that allows you to do everything you want without having to even program the computer. However you might get the hardware with a device driver and some guidelines on how to communicate with it, but you end up having to do most of the programming yourself.

I don't know anything about the nature of such devices so giving any more advice would be speculative.

As for the first question, I think windows has a library for this kind of thing. Have you looked at DirectSound? Its part of the DirectX package and is windows specific. Also hardware vendors have to supply their own interface in their device driver so any platform issues outside of windows should be ok.
 
chiro said:
Hey da_coolest and welcome to the forums.

For your second question, you may have a few options but if you can still a peripheral card that allows to stream the data straight from your medical device to the computer, then that will be a viable option.

Using the above device will depend on the nature of the device and who made it. For example you might get a device that comes with a complete software package and device driver that allows you to do everything you want without having to even program the computer. However you might get the hardware with a device driver and some guidelines on how to communicate with it, but you end up having to do most of the programming yourself.

I don't know anything about the nature of such devices so giving any more advice would be speculative.

As for the first question, I think windows has a library for this kind of thing. Have you looked at DirectSound? Its part of the DirectX package and is windows specific. Also hardware vendors have to supply their own interface in their device driver so any platform issues outside of windows should be ok.

Thanks for the reply. The device that I have is a very simple one made by myself. Its picking up electric signals through electrodes and amplifying using an opamp. I thought of using the soundcard's inputs to connect the output of the amp to the pc.

I found several multimedia libraries that allows to record input signals from the sound card (SFML). But I want to achieve is to extract data enough to draw the ECG diagram (amplitude versus time) . And then to recognize peak points of the input signal to determine heart pulses.
 
da_coolest said:
Thanks for the reply. The device that I have is a very simple one made by myself. Its picking up electric signals through electrodes and amplifying using an opamp. I thought of using the soundcard's inputs to connect the output of the amp to the pc.

I found several multimedia libraries that allows to record input signals from the sound card (SFML). But I want to achieve is to extract data enough to draw the ECG diagram (amplitude versus time) . And then to recognize peak points of the input signal to determine heart pulses.

I'm guessing you are getting a PCM form of the data. Is this true?

If this is the case, you should be able to just to find global and local maximums by just doing a loop through your data and just storing data when you find a local maximum (has been continually increasing until certain point).

So you would something like:

Code:
int lastsample = sample[0];
for (int i = 1; i < numSamples; i++)
{
   // Assume that each sample is a signed integer that has the required resolution
   if (sample[numSamples] < lastSample)
  {
       // You have a local peak so do stuff here
  }
  lastSample = sample[numSamples];
}

Of course this is very simple, but if you just want to find local peaks, then if it is in amplitude form it should do the trick.
 
chiro said:
I'm guessing you are getting a PCM form of the data. Is this true?

If this is the case, you should be able to just to find global and local maximums by just doing a loop through your data and just storing data when you find a local maximum (has been continually increasing until certain point).

So you would something like:

Code:
int lastsample = sample[0];
for (int i = 1; i < numSamples; i++)
{
   // Assume that each sample is a signed integer that has the required resolution
   if (sample[numSamples] < lastSample)
  {
       // You have a local peak so do stuff here
  }
  lastSample = sample[numSamples];
}

Of course this is very simple, but if you just want to find local peaks, then if it is in amplitude form it should do the trick.

Thanks. But can you suggest a good method to capture signal through the sound card inputs that would allow me to analyze captured signal?

I have read about some multimedia libraries available for C++, but most are seems to be just allowing to record data and save them to a file, or to play back etc.
 
da_coolest said:
Thanks. But can you suggest a good method to capture signal through the sound card inputs that would allow me to analyze captured signal?

I have read about some multimedia libraries available for C++, but most are seems to be just allowing to record data and save them to a file, or to play back etc.

DirectSound would be your best bet.

The DirectX library allows you to interface directly with hardware at the lowest possible level permitted by the OS (unless you have some kind of custom driver or something like that).

This includes among other things, getting the exact keyboard and mouse states that are not filtered out by windows events as well getting screen buffer information from the graphics card.

It does the same sort of thing for the soundcard: You should be able to get the raw data directly from your soundcard in an appropriate format.

You should take a look at this if you haven't already:

http://msdn.microsoft.com/en-us/library/windows/desktop/ee416968(v=vs.85).aspx
 
chiro said:
DirectSound would be your best bet.

The DirectX library allows you to interface directly with hardware at the lowest possible level permitted by the OS (unless you have some kind of custom driver or something like that).

This includes among other things, getting the exact keyboard and mouse states that are not filtered out by windows events as well getting screen buffer information from the graphics card.

It does the same sort of thing for the soundcard: You should be able to get the raw data directly from your soundcard in an appropriate format.

You should take a look at this if you haven't already:

http://msdn.microsoft.com/en-us/library/windows/desktop/ee416968(v=vs.85).aspx

Thanks a lot for all the information you have provided. I will start reading about directsound. thanks again.
 

Similar threads

Replies
10
Views
5K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 5 ·
Replies
5
Views
43K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
13
Views
1K
  • · Replies 14 ·
Replies
14
Views
5K
  • · Replies 4 ·
Replies
4
Views
19K
  • · Replies 40 ·
2
Replies
40
Views
5K
  • · Replies 21 ·
Replies
21
Views
3K