MacMusic.org  |  PcMusic.org  |  440Software  |  440Forums.com  |  440Tv  |  Zicos.com  |  AudioLexic.org
Loading... visitors connected
Welcome Guest

darkeye

Profile
Personal Photo
Avatar
Members

Newbie
Rating
 
Options
Options
Pro Infos

Personal Info
Gender Not Set
Birthday Unknown
1066 Budapest
Hungary
darkeye doesn't have a personal statement currently.
Statistics
Joined: 25-Feb 04
Profile Views: 229*
Last Seen: Mon 11 May 2009, 07:22
Local Time: Sun 22 Sep 2024, 00:42
1 posts (0 per day)
Contact Information
AIM No Information
Yahoo No Information
ICQ No Information
MSN No Information
* Profile views updated each hour
Topics
Posts
Blog
Comments
Friends
My Content
25 Feb 2004
Hi,

I'm new to MacOS programming, but have considerable background in different UNIX systems. I'm trying to port my project, DarkIce to MacOS. For this, I need to be able to simply record audio from an audio device. More precisely:
  • open the audio device
  • configure for appropriate parameters (e.g. 44.1kHz, 16 bit, 2 channel, PCM recording)
  • read from the device
  • close the device
for example, on Solaris / OpenBSD / NetBSD, the following code achieves just this:
CODE
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <sys/audioio.h>

#define FILE_NAME "/dev/audio"
#define SAMPLE_RATE 22050
#define CHANNEL 2
#define BITS_PER_SAMPLE 16
#define BUF_SIZE 4

int main(int argc, char **argv) {
   int             fd;
   audio_info_t    audioInfo;
   unsigned char   buf[BUF_SIZE];
   unsigned int    len = BUF_SIZE;
   ssize_t         ret;

   fd = open( FILE_NAME, O_RDONLY);

   AUDIO_INITINFO( &audioInfo);
   audioInfo.record.sample_rate = SAMPLE_RATE;
   audioInfo.record.channels    = CHANNEL;
   audioInfo.record.precision   = BITS_PER_SAMPLE;
   audioInfo.record.encoding    = AUDIO_ENCODING_LINEAR;

   if ( ioctl(fd, AUDIO_SETINFO, &audioInfo) ) {
       printf("can't set audio info, error: %d\n", errno);
   }

   ret = read(fd, buf, len);

   printf("%d returned by read\n", ret);
   if ( ret == -1 ) {
       printf("error code %d\n", errno);
   }

   close(fd);

   return 0;
}

What I hear is that MacOS uses a callback pattern to access audio data from the sound card. if so, probably I'm looking for a sample that does:
  • initialize the whole thing
  • set the audio parameters (e.g. 44.1kHz 16 bit stereo PCM recording)
  • register my callback function
  • shut down
Can anyone help me?
Last Visitors
darkeye has no visitors to display.

Comments
Other users have left no comments for darkeye.

Friends
There are no friends to display.
Lo-Fi Version - Sun 22 Sep 2024, 01:42
- © MacMusic 1997-2008