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

In summary: 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:int lastsample = sample[0];for (int i = 1; i < numSamples; i++){ // Assume that each sample is a signed 16 bit integer...if (lastsample > max){max = lastsample;}}Thanks for the reply. The device that
  • #1
da_coolest
15
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
  • #2
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.
 
  • #3
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.
 
  • #4
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.
 
  • #5
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.
 
  • #6
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
 
  • #7
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.
 

1. How does an electric signal get converted into sound through a sound card?

The process of converting an electric signal into sound through a sound card involves several steps. First, the electric signal is received by the sound card and converted into a digital format using an analog-to-digital converter. Then, the digital signal is processed by the sound card's software, which adjusts the signal's amplitude and frequency. Finally, the digital signal is converted back into an analog format using a digital-to-analog converter and sent to the speakers to produce sound.

2. What components are necessary for reading an electric signal through a sound card?

To read an electric signal through a sound card, you will need a computer with a sound card installed, an audio cable to connect the signal source to the sound card, and appropriate software for processing and interpreting the signal.

3. Can any sound card be used to read an electric signal?

No, not all sound cards are capable of reading electric signals. The sound card must have an analog-to-digital converter and a digital-to-analog converter to process the signal. Additionally, some sound cards may have limited input options or may not be compatible with the software needed for processing the signal.

4. Is it possible to read multiple electric signals simultaneously through a sound card?

Yes, it is possible to read multiple electric signals simultaneously through a sound card. This can be achieved by using multiple input channels on the sound card or by using software that can process and interpret multiple signals at once.

5. How accurate is reading an electric signal through a sound card compared to other methods?

The accuracy of reading an electric signal through a sound card depends on various factors, such as the quality of the sound card, the software being used, and the complexity of the signal being read. In general, sound cards can provide accurate readings for most signals, but for highly precise measurements, other methods such as oscilloscopes may be more suitable.

Similar threads

  • Programming and Computer Science
Replies
10
Views
3K
Replies
12
Views
1K
  • Electrical Engineering
Replies
25
Views
3K
  • Special and General Relativity
2
Replies
40
Views
2K
Replies
6
Views
2K
  • Programming and Computer Science
Replies
1
Views
4K
Replies
14
Views
3K
  • General Engineering
Replies
2
Views
4K
  • Electrical Engineering
Replies
4
Views
1K
  • Introductory Physics Homework Help
Replies
1
Views
952
Back
Top