-> click here to download SwaN-MR and
other freeware for Mac OS X <-
Writing a converter TO the SwaN-MR format is very easy. Things are complicated if you want convert FROM SwaN-MR but this is not addressed in this page. Your program should include the following code:
typedef struct { long pts, dgt;float width, Hz, MHz;short protocol, options; } Layer;typedef struct { float re, im; } complex;long n, /* number of complex points */howMuch,header = (long*) NewPtrClear(512); /* a Macintosh function */short i, dimension; /* normally 1 or 2 */Layer L[5];complex *data; /* assuming this already contains your data */#if (! your_spectra_are_like_Bruker)for (i = 0; i < n; i++)data[i].im = - data[i].im;#endifL->pts = 1;L->dgt = 1;L->width = 1000;L->Hz = 0;L->MHz = 100;L->protocol = 0;L->options = 1;for (i = 1; i <= 4; i++)L[i] = L[0];for (i = 1; i <= dimension; i++) {L[i].pts = n; /* modify if dimension > 1 !!! */L[i].dgt = L[i].pts;L->width = your_spectral_width;L->Hz = frequency_at_the_right_end_of_the_spectrum;L-> MHz = spectrometer_frequency;}header[0] = 32;header[1] = 8 * n;header[33] = dimension << 16;/* assuming your file is open and refnum = the file reference number */howMuch = 512;FSWrite (refNum, &howMuch, (Ptr) header);howMuch = 8 * n;FSWrite (refNum, &howMuch, (Ptr) data);SetFPos(refNum, fsFromStart, 32);howMuch = 4 * sizeof(Layer);FSWrite (refNum, &howMuch, (Ptr) &L[1]);FSClose (refNum);DisposPtr ((Ptr) header);