0
0

.L

  • You must to post comments
0
0

Super Nickel Brett.

I put your code inside my engine, 10 minutes later, it was working pretty fine with a Super low latency (for my advice).
I ll take alook at your new correction cause there’s some kind of strange noise sometimes but it was working pretty fine without correction.

I ll give u a BIG kiss ;).

I ll post the final code for those who want to do the same things this week.

c u soon.

PS :
memcpy(mybuffer, ptrw + (mylength_bytes – myoffset_bytes), len2 – (mylength_bytes – myoffset_bytes));
–> I assume ptrw is ptr2 ?!.

  • You must to post comments
0
0

Hello,
In your code, what is the interest of the:

[code:1u1cbfld]
if (myoffset_bytes + len1 <= mylength_bytes)
{
...
}
else
{
// mybuffer wraps around
...
}
[/code:1u1cbfld]

and

[code:1u1cbfld]
if (myoffset_bytes + len2 <= mylength_bytes)
{
...
}
else
{
// mybuffer wraps around
...
}
[/code:1u1cbfld]

as (ptr1,len1) is described to be the unwrapped part of the sample and (ptr2,len2) the wrapped part of the sample in the FSOUND_Sample_Lock help of FMOD?
Thanks,
David

  • You must to post comments
0
0

๐Ÿ˜ณ Oops, so many excuses about that, I didn’t go deep enough in the code to see that (myoffset_bytes,mylength_bytes) was the destination buffer!
Thanks for the help… again
David

  • You must to post comments
0
0

Forget the exemple i sent first, this is shit and unreadable. Here’s a new source taken directly from your USERSTREAM exemple. I just add the Input in init and add a Sample to contain Microphone.
This exemple of course doesn’t work like i want. (doesn’t work with microphone). U can compile it and test, u should hear some crapy noise (instead of your voice).
I comment it a lot to help my helper :). So if u can help me, i m locked on this problem for 5 days now :( i m gonna be crazy, i just wanna take the input, that’s shouldn’t be as complicated.

Tanks, Wax.

Ps : (Please don’t gimme solution with a Dsp, or stg like that … ๐Ÿ˜‰

http://wax78.dyndns.org/W_SYNTH/downloa … gtoMic.cpp


Here’s a little paste if u just want to take a lot without d/l file and execute it

include <stdio.h>

include <math.h>

if defined(WIN32) || defined(_WIN64) || defined(WATCOMC)

#include <conio.h>
#include <windows.h>

else

#include “../../api/inc/wincompat.h”

endif

include “../../api/inc/fmod.h”

include “../../api/inc/fmod_errors.h” // optional

int init_fmod();

FSOUND_STREAM *stream; // the Stream that user should hear : Some sound modded by the microphone
FSOUND_SAMPLE *samp1; // The “buffer” of the microphone, that will be used in the CallBack to put controle the synth stream. (or anything u want)

define RECORDRATE 44100

//#define RECORDLEN (RECORDRATE * 10) /* 1 seconds at RECORDRATE khz */

define RECORDLEN 4 /* 1 seconds at RECORDRATE khz */ // (try to reduce error of reading memory (4 chance instead of a lot, but not sure it ll work fine with only 4 byte of buffer)

define OUTPUTRATE 44100

// the sound output, so no problem, but no way to read my microphone and use the value
// for my synthesis
// Like this, u should hear ur voice without playing Samp1 stream (the purpose i want)
signed char F_CALLBACKAPI streamcallback(FSOUND_STREAM *stream, void *buff, int len, void *param)
{
// Use for synthesis
int count;
static float t1 = 0, t2 = 0; // time
static float v1 = 0, v2 = 0; // velocity
signed short *stereo16bitbuffer = (signed short *)buff;

// Used to receive micro value
unsigned int len1, len2;
int lenbytes=4; // For 16 bit stereo (juste want a sample)
signed short *ptr_sample,ptr2;
signed short int MICRO_INPUT;

for (count=0; count&lt;len&gt;&gt;2; count++)        // &gt;&gt;2 = 16bit stereo (4 bytes per sample)
{
    // Try to the the actual micro value :| there's the problem
    FSOUND_Sample_Lock(samp1,FSOUND_Record_GetPosition(), lenbytes, (void**)&amp;ptr_sample, (void**)&amp;ptr2, &amp;len1, &amp;len2);
        MICRO_INPUT=ptr_sample[0];
        if (rand()%50==1)   // Draw sometime on screen to look MICRO_INPUT Value (must be &lt;=300 if nothing input on micro, so if i see something else it doesn't work)   
        printf("[%6d][%d]\n", FSOUND_Record_GetPosition(),MICRO_INPUT);
    FSOUND_Sample_Unlock(samp1, (void**)&amp;ptr_sample, (void**)&amp;ptr2, len1,len2);

    // Resend micro directly to output so if i can hear my voice, it's good (but i only hear KrzzChhhKshchhHHH)
    *stereo16bitbuffer++ = (signed short)MICRO_INPUT;              // left channel
    *stereo16bitbuffer++ = (signed short)MICRO_INPUT;              // right channel

    t1 += 0.01f   + v1;
    t2 += 0.0142f + v2;
    v1 += (float)(sin(t1) * 0.002f);
    v2 += (float)(sin(t2) * 0.002f);

/* // different test for when MICRO_INPUT is good.
//Normal synthesis coming from exemple
*stereo16bitbuffer++ = (signed short)(sin(t1) * 32767.0f); // left channel
*stereo16bitbuffer++ = (signed short)(sin(t2) * 32767.0f); // right channel
//Amplitude controled synthesis with microphone (should work when Micro_Input work)
*stereo16bitbuffer++ = (signed short)(sin(t1) * MICRO_INPUT); // left channel
*stereo16bitbuffer++ = (signed short)(sin(t2) * MICRO_INPUT); // right channel
*/
}
printf(“callback : buff = %p, len = %d, time = %.02f param = %d\n”, buff, len, (float)FSOUND_Stream_GetTime(stream) / 1000.0f, param);
return 1;
}

int main()
{
int r = init_fmod(); // Init all balbalbalbla (it works fine)

////// MIC or LINE IN Recording (to feed the synthesis stream in the callback)
// Microphone input, need to be taken each time Stream (instrument_callback) evolve.
if (FSOUND_GetOutput() == FSOUND_OUTPUT_OSS)
{
samp1 = FSOUND_Sample_Alloc(FSOUND_UNMANAGED, RECORDLEN, FSOUND_MONO | FSOUND_8BITS | FSOUND_UNSIGNED, RECORDRATE, 255, 128, 255);
}
else
{
samp1 = FSOUND_Sample_Alloc(FSOUND_UNMANAGED, RECORDLEN, FSOUND_STEREO | FSOUND_16BITS , RECORDRATE, 255, 128, 255);
}

FSOUND_Sample_SetMode(samp1, FSOUND_LOOP_NORMAL);   /* make it a looping sample */
// Start recording to the ring buffer
if (!FSOUND_Record_StartSample(samp1, TRUE))    /* start recording and make it loop also */
{
    printf("Error!\n");
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
    FSOUND_Close();exit(-1);return 0;
}
while (!FSOUND_Record_GetPosition())  {Sleep(1);}

////// SYNTHESIS STREAM
// CREATE USER STREAM (the one i use for my synthesis)
stream = FSOUND_Stream_Create(streamcallback, 3*4096, FSOUND_NORMAL | FSOUND_16BITS | FSOUND_STEREO, 44100, (void *)12345);
if (!stream)
{
printf(“Error!\n”);
printf(“%s\n”, FMOD_ErrorString(FSOUND_GetError()));
return 1;
}
// PLAY synthesis STREAM
if (FSOUND_Stream_Play(FSOUND_FREE, stream) == -1)
{
printf(“Error!\n”);
printf(“%s\n”, FMOD_ErrorString(FSOUND_GetError()));
return 1;
}

// Yes, :( in fact i just wanna record, not play it (but for my test i need to playback for looking if microphone work) 
//int Microphone_Channel= FSOUND_PlaySound(FSOUND_FREE,samp1); 

getch(); // wait for end (while(1))
FSOUND_Stream_Close(stream);
FSOUND_Close();
return 0;

}

  • You must to post comments
0
0

Here’s the complete code, withou all my synthese part (i brief it to show a simple exemple). It surely can be optimised :). (It should be interesting to have the Function u made Brett in future exemple of fmod no ? for people like me :D).

This

http://wax78.dyndns.org/NOOBSYNTH/downl … e/Main.cpp

or

// Base from Record.cpp and Brett copie_Sample_Micro_vers_ring_buffer_micro() function

include <stdio.h>

include <stdlib.h>

include <math.h>

if defined(WIN32) || defined(WATCOMC) || defined(_WIN32) || defined(WIN32)

#include &lt;conio.h&gt;
#include &lt;windows.h&gt;
#define __PACKED /*dummy*/

else

#include "../../api/inc/wincompat.h"
#include &lt;string.h&gt;
#define __PACKED __attribute__((packed)) /* gcc packed */

endif

include “../../api/inc/fmod.h”

include “../../api/inc/fmod_errors.h” /* optional */

define PI 3.141517

define RECORDRATE 44100

define RECORDLEN (RECORDRATE * 5) /* 5 seconds at RECORDRATE khz */

define OUTPUTRATE 44100

int BufferSize=4096*3;
int Frequency=44100;
signed short MICRO_INPUT=0;

FSOUND_SAMPLE *samp1;
FSOUND_STREAM *stream;

int mylength_bytes=44100400;
signed short mybuffer[44100
400+10];
unsigned int myoffset_bytes=0;

signed char F_CALLBACKAPI instrument_callback(FSOUND_STREAM *stream, void *buff, int len, void *param);
int copie_Sample_Micro_vers_ring_buffer_micro();

int main(int argc, char *argv[])
{

signed char key;
int driver, i, channel, originalfreq;

if (FSOUND_GetVersion() &lt; FMOD_VERSION)
{
    printf("Error : You are using the wrong DLL version!  You should be using FMOD %.02f\n", FMOD_VERSION);
    return 0;
}

/*
    SELECT OUTPUT METHOD
*/

printf("---------------------------------------------------------\n");  
printf("Output Type\n");    
printf("---------------------------------------------------------\n");  

if defined(WIN32) || defined(_WIN64) || defined(CYGWIN32) || defined(WATCOMC)

printf("1 - Direct Sound\n");
printf("2 - Windows Multimedia Waveout\n");
printf("3 - NoSound\n");

elif defined(linux)

printf("1 - OSS - Open Sound System\n");
printf("2 - ESD - Elightment Sound Daemon\n");
printf("3 - ALSA 0.9 - Advanced Linux Sound Architecture\n");   

endif

printf("---------------------------------------------------------\n");  /* print driver names */
printf("Press a corresponding number or ESC to quit\n");

do
{
    key = getch();
} while (key != 27 &amp;&amp; key &lt; '1' &amp;&amp; key &gt; '4');

switch (key)
{

if defined(WIN32) || defined(_WIN64) || defined(CYGWIN32) || defined(WATCOMC)

    case '1' :  FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
                break;
    case '2' :  FSOUND_SetOutput(FSOUND_OUTPUT_WINMM);
                break;
    case '3' :  FSOUND_SetOutput(FSOUND_OUTPUT_NOSOUND);
                break;

elif defined(linux)

    case '1' :  FSOUND_SetOutput(FSOUND_OUTPUT_OSS);
                break;
    case '2' :  FSOUND_SetOutput(FSOUND_OUTPUT_ESD);
                break;
    case '3' :  FSOUND_SetOutput(FSOUND_OUTPUT_ALSA);
                break;

endif

    default :   return 0;
}

/*
    SELECT OUTPUT DRIVER
*/

/* The following list are the drivers for the output method selected above. */
printf("---------------------------------------------------------\n");  
switch (FSOUND_GetOutput())
{
    case FSOUND_OUTPUT_NOSOUND:    printf("NoSound"); break;
    case FSOUND_OUTPUT_WINMM:      printf("Windows Multimedia Waveout"); break;
    case FSOUND_OUTPUT_DSOUND:     printf("Direct Sound"); break;
    case FSOUND_OUTPUT_OSS:        printf("Open Sound System"); break;
    case FSOUND_OUTPUT_ESD:        printf("Enlightment Sound Daemon"); break;
    case FSOUND_OUTPUT_ALSA:       printf("ALSA"); break;       
};
printf(" Driver list\n");   
printf("---------------------------------------------------------\n");  

for (i=0; i &lt; FSOUND_GetNumDrivers(); i++) 
{
    printf("%d - %s\n", i+1, FSOUND_GetDriverName(i));  /* print driver names */
}
printf("---------------------------------------------------------\n");  /* print driver names */
printf("Press a corresponding number or ESC to quit\n");

do
{
    key = getch();
    if (key == 27) 
    {
        FSOUND_Close();
        return 0;
    }
    driver = key - '1';
} while (driver &lt; 0 || driver &gt;= FSOUND_GetNumDrivers());

FSOUND_SetDriver(driver);                   /* Select sound card (0 = default) */

/*
    SELECT MIXER
*/

FSOUND_SetMixer(FSOUND_MIXER_QUALITY_AUTODETECT);

/*
    INITIALIZE
*/
if (!FSOUND_Init(OUTPUTRATE, 64, FSOUND_INIT_ACCURATEVULEVELS))
{
    printf("Error!\n");
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
    return 0;
}


/*
    SELECT INPUT DRIVER (can be done before or after init)
*/

/* The following list are the drivers for the output method selected above. */
printf("---------------------------------------------------------\n");  
switch (FSOUND_GetOutput())
{
    case FSOUND_OUTPUT_NOSOUND:    printf("NoSound"); break;
    case FSOUND_OUTPUT_WINMM:      printf("Windows Multimedia Waveout"); break;
    case FSOUND_OUTPUT_DSOUND:     printf("Direct Sound"); break;
    case FSOUND_OUTPUT_OSS:        printf("Open Sound System"); break;
    case FSOUND_OUTPUT_ESD:        printf("Enlightment Sound Daemon"); break;
    case FSOUND_OUTPUT_ALSA:       printf("ALSA"); break;       
};
printf(" Recording device driver list\n");  
printf("---------------------------------------------------------\n");  

for (i=0; i &lt; FSOUND_Record_GetNumDrivers(); i++) 
{
    printf("%d - %s\n", i+1, FSOUND_Record_GetDriverName(i));   /* print driver names */
}
printf("---------------------------------------------------------\n");  /* print driver names */
printf("Press a corresponding number or ESC to quit\n");

do
{
    key = getch();
    if (key == 27) 
        return 0;
    driver = key - '1';
} while (driver &lt; 0 || driver &gt;= FSOUND_Record_GetNumDrivers());

if (!FSOUND_Record_SetDriver(driver))   /* Select input sound card (0 = default) */
{
    printf("Error!\n");
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
    FSOUND_Close();
    return 0;
}

/*
    DISPLAY HELP
*/

printf("FSOUND Output Method : ");
switch (FSOUND_GetOutput())
{
    case FSOUND_OUTPUT_NOSOUND:    printf("FSOUND_OUTPUT_NOSOUND\n"); break;
    case FSOUND_OUTPUT_WINMM:      printf("FSOUND_OUTPUT_WINMM\n"); break;
    case FSOUND_OUTPUT_DSOUND:     printf("FSOUND_OUTPUT_DSOUND\n"); break;
    case FSOUND_OUTPUT_OSS:        printf("FSOUND_OUTPUT_OSS\n"); break;
    case FSOUND_OUTPUT_ESD:        printf("FSOUND_OUTPUT_ESD\n"); break;
    case FSOUND_OUTPUT_ALSA:       printf("FSOUND_OUTPUT_ALSA\n"); break;       
};

printf("FSOUND Mixer         : ");
switch (FSOUND_GetMixer())
{
    case FSOUND_MIXER_BLENDMODE:    printf("FSOUND_MIXER_BLENDMODE\n"); break;
    case FSOUND_MIXER_MMXP5:        printf("FSOUND_MIXER_MMXP5\n"); break;
    case FSOUND_MIXER_MMXP6:        printf("FSOUND_MIXER_MMXP6\n"); break;
    case FSOUND_MIXER_QUALITY_FPU:  printf("FSOUND_MIXER_QUALITY_FPU\n"); break;
    case FSOUND_MIXER_QUALITY_MMXP5:printf("FSOUND_MIXER_QUALITY_MMXP5\n"); break;
    case FSOUND_MIXER_QUALITY_MMXP6:printf("FSOUND_MIXER_QUALITY_MMXP6\n"); break;
};
printf("FSOUND Driver        : %s\n", FSOUND_GetDriverName(FSOUND_GetDriver()));
printf("FSOUND Record Driver : %s\n", FSOUND_Record_GetDriverName(FSOUND_Record_GetDriver()));

// My stream for my synthetiseur circuit (wich need to be feeded by the micro)
stream = FSOUND_Stream_Create(instrument_callback, BufferSize, FSOUND_16BITS | FSOUND_SIGNED | FSOUND_STEREO |FSOUND_NONBLOCKING, Frequency, (void *)NULL);
if (!stream)
{
    printf("Error!\n");
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
    exit(1);
}   
// Play the synthetiseur channel cause we wanna hear some good sounds ;)
if (FSOUND_Stream_Play(FSOUND_FREE, stream) == -1) {printf("Error!\n");printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));exit(1);}

/*
    Create a sample to record into
*/
if (FSOUND_GetOutput() == FSOUND_OUTPUT_OSS)
{
    samp1 = FSOUND_Sample_Alloc(FSOUND_UNMANAGED, RECORDLEN, FSOUND_MONO | FSOUND_8BITS | FSOUND_UNSIGNED, RECORDRATE, 255, 128, 255);
}
else
{
    samp1 = FSOUND_Sample_Alloc(FSOUND_UNMANAGED, RECORDLEN, FSOUND_STEREO | FSOUND_16BITS , RECORDRATE, 255, 128, 255);
}

printf("\n");
printf("=========================================================================\n");
printf("Press a key to start recording 5 seconds worth of data\n");
printf("=========================================================================\n");

if (!FSOUND_Record_StartSample(samp1, FALSE))   /* it will record into this sample for 5 seconds then stop */
{
    printf("Error!\n");
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
    FSOUND_Close();
    return 0;
}


FSOUND_Sample_SetMode(samp1, FSOUND_LOOP_NORMAL);   /* make it a looping sample */
if (!FSOUND_Record_StartSample(samp1, TRUE))    /* start recording and make it loop also */
{
    printf("Error!\n");
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));

    FSOUND_Close();
    return 0;
}

while (1) // ;) forget that piggery.
{
    printf("Boucle Main\n");
    Sleep(100);
}

FSOUND_StopSound(channel);
FSOUND_Record_Stop();
FSOUND_Sample_Free(samp1);
FSOUND_Close();
return 0;

}

// This Came From Brett, The super man of Fmod ๐Ÿ˜‰
// Retour : Position a jouer (car dernier morceau copie)
int copie_Sample_Micro_vers_ring_buffer_micro()
{
static int oldposition = 0;
int newposition = FSOUND_Record_GetPosition();
int offs=0;
if (newposition != oldposition)
{
void *ptr1, *ptr2;
unsigned int len1, len2;
int length = newposition – oldposition;
if (length < 0) // new position might have wrapped around to 0!
{
length += FSOUND_Sample_GetLength(samp1);
}
FSOUND_Sample_Lock(samp1, oldposition * 4, length * 4, &ptr1, &ptr2, &len1, &len2); // *4 = 16bit stereo

offs=myoffset_bytes;
if (myoffset_bytes + len1 &lt;= mylength_bytes) 
{ 
    memcpy(mybuffer + myoffset_bytes, ptr1, len1); 
    myoffset_bytes += len1; 
} 
else 
{ 
    // mybuffer wraps around 
    memcpy(mybuffer + myoffset_bytes, ptr1, mylength_bytes - myoffset_bytes); 
 //   memcpy(mybuffer, ptr1 + (mylength_bytes - myoffset_bytes), len1 - (mylength_bytes - myoffset_bytes)); 
    memcpy(mybuffer,
        (signed short*)ptr1 + (mylength_bytes - myoffset_bytes),
        len1 - (mylength_bytes - myoffset_bytes)
        ); 

    myoffset_bytes += len1; 
    myoffset_bytes -= mylength_bytes; 
} 

if (len2) 
{ 
    if (myoffset_bytes + len2 &lt;= mylength_bytes) 
    { 
        memcpy(mybuffer + myoffset_bytes, ptr2, len2); 
        myoffset_bytes += len2; 
    } 
    else 
    { 
        // mybuffer wraps around 
        memcpy(mybuffer + myoffset_bytes, ptr2, mylength_bytes - myoffset_bytes); 
        memcpy(mybuffer, (signed short*)ptr2 + (mylength_bytes - myoffset_bytes), len2 - (mylength_bytes - myoffset_bytes)); 

        myoffset_bytes += len2; 
        myoffset_bytes -= mylength_bytes; 
    } 
} 

FSOUND_Sample_Unlock(samp1, ptr1, ptr2, len1, len2); 

oldposition += length; 
if (oldposition &gt;= FSOUND_Sample_GetLength(samp1) )
{ 
    oldposition -= FSOUND_Sample_GetLength(samp1); 
} 

}
return(offs);
}

signed char F_CALLBACKAPI instrument_callback(FSOUND_STREAM stream, void *buff, int len, void *param) {
{
static float MX=0;
signed short *stereo16bitbuffer = (signed short *)buff;
static float t=0,dx=0;
int i=0;
int channel=0;
// I do it there to be sure of the sync, it seem to work not less than if that were in main …
int offs = copie_Sample_Micro_vers_ring_buffer_micro();
float osc_result= 0;
for (float x=0;x<len>>2;x++)
{
t++;
// Obtain actual micro value (to normally give it to synth but not there)
MICRO_INPUT = (signed short)mybuffer[(int)offs];
// Here normally i generate sound with my synthesizer class, but i brief a lot …
//osc_result=(float)(rand()%100)/100; // For Tv like Noise
osc_result=sin(t
2*PI/180); // For Sinusoidal VCO

// I modulate the Synth signal with MicroInput in this exemple (AM)
        *stereo16bitbuffer = ((float)MICRO_INPUT/32767)*(osc_result*32767);
        *(stereo16bitbuffer+1) =((float)MICRO_INPUT/32767)*(osc_result*32767);

// Fait avancer le ring buffer du micro et evite le depassement (ring buffer offset++)
        offs+=2;
        if((offs &gt;= mylength_bytes) &amp;&amp; (offs &lt; 0) )
        { 
            offs = 0; 
        } 
        stereo16bitbuffer+=2;
    }
}
return(1);

}

  • You must to post comments
0
0

Can someone help me please, or my question is not Easy or what ?

  • You must to post comments
0
0

There’s something strange with memory. It leaks inside

copie_Sample_Micro_vers_ring_buffer_micro();

It seems to leak on the Lock and Memcopy (that’s strange). May i delete ptr1 ? (i tryed, but don’t work then thought Unlock will do it, but doesn’t seem).

Someone’s got idea?

  • You must to post comments
0
0

That’s exactly what i was frighten … The record exemple ๐Ÿ˜‰ (i m jockin’) i looked several time… the code listed here is taken from your record exemple, without the Dsp + some modifications.

>>i can’t work out what you’re trying to do, you are trying to playback the sound that you record?

Yes, in this simple exemple that’s what i try to do, just put “the micro” on the “Speaker” (i mean from Input of the sound card, to a stream channel that’s playing). That’s the more convenient way for all my work.

>> The record example already does that.
Hu, i don’t seen Any Lock/Unlock way of doing that ๐Ÿ˜‰ (that’s not a attack). I just see a PlayChannel for the microphone for 1 st exemple. Then the use of a DSP for 2 nd exemple. I try to “Hack” the first exemple, i just arrive to detect some sort of interaction with micro (values where like the level of the micro) but in fact the thing i hear was more Krchchch Krrcchchch (noise:()
. So i tryed to use the Dsp to get the micro value : That’s work. but i was hearing the sound of the microphone cause of the Playchannel. I put NewBuffer = NULL inside the Dspcallback then i receive the info i wan for the buffer, but no sound output. But I got Microphone + my synthesis channel (the playing one) inside this buffer, and i just want the microphone one… so no way with that.

Otherwise why would you need a custom stream? That is for playback.

>> Because i make a software modular synth, and i need inputs (Keyboard, sequencer, and Analog Input like Voice, or line in ….). I ll use it for exemple making a vocoder. But i can make a simple synth that just make sound and don’t need input.
So i use a stream to make the synthesis output and hear a Piano or what u want that make sound. I got a microphone Class that shall receive the actual “value” of the micro. like this i can use my Micro everywhere i want in my synth. So i need a Playback of my synth, and i use the custom stream. It was working fine since i need to integrate the microphone. I m loosing all my time on this.

I hope it’s enough comprehensible. So please help me to find a way, im desesperate to block on this.

Wax.

  • You must to post comments
0
0

really similar to what i want to do …
Is it possible to havea buffer of only 0.1ms with fmod ?

  • You must to post comments
0
0

>> if you’re just wanting to do an effect and the record example already plays back the data, then yes, use DSP.

No i absolutely not want it. No want to Hear my voice, With or withour Modification :)

>> Its far simpler to do this than the huge amount of broken code you have posted above.

It’s broken and doesn’t work, that’s true. But more simple… it depends, i find more simple like this, than A dsp Callback that’s done magical by fmod ๐Ÿ˜‰

>> You don’t need lock and unlock, that is only if you want to modify the existing FSOUND_SAMPLE or copy it somewhere.

Fiouf, Copy It somewhere, in my synth (somewhere in a class), Sample by sample :) i wanna. So how to copy the data from FSOUND_SAMPLE withou unlock ? I don’t wanna modify FSOUND_SAMPLE just read the value inside.

>>>looking at your lock logic above, it looks fairly broken, you are grabbing bits of sound data (1 sample?) using FSOUND_Record_GetPosition() as the offset? What are you hoping to achieve there? You know the record position is probably the same value the whole time? (because it moves up in chunks) It doesn’t incremement one sample at a time.

No i don’t know, i had not made FMOD … :) i’m just trying to use it … and try to find solution with you.
I tryed, 0 as the offset, all value u want, i tried all logic i can imagine ………..
The Record position with 4 Bytes is 32103210321032103210 always (caus of the ring) (offset) i look at the Value returned by Record_Getposition().
For the Xth time ๐Ÿ˜‰ it try to take the actual SAMPLE value of the microphone to use it (TO COPY the value inside a Short int that i can reuse in my synthesis engine, i Need absolutely the Value).

i did a new code with Old_Pos:
if (old_rec_pos!=FSOUND_Record_GetPosition())
{
lenbytes=FSOUND_Sample_GetLength(samp1);
int r=FSOUND_Sample_Lock(samp1,0+x, lenbytes, (void)&ptr_sample, (void)&ptr2, &len1, &len2);

        MICRO_INPUT=(signed short )ptr_sample[old_rec_pos*2]; // Tried with or without *2 ...
        printf("[%6d][%d]\n", FSOUND_Record_GetPosition(),MICRO_INPUT);
        r=FSOUND_Sample_Unlock(samp1, (void**)&amp;ptr_sample, (void**)&amp;ptr2, len1,len2);
        old_rec_pos=FSOUND_Record_GetPosition();

}

That’s seem to not work, But, it react when i Shout on my micro, but what i rec is not my shout, …

>>Also the record position is what it is currently RECORDING into, not what is available.
Ok so this return the * to the last data written, so i need to take the OLD_RECORD_POS … that’s it ? (i tried)

>> you shouldnt be referring to data that is still being written over, you will get half of the old buffer and half of the new buffer probably. Just get rid of that whole logic, i think you are in totally the wrong ballpark.
MMM, that’s possible i m not in the good direction, that’s possible also that i explain very badly, and that’s also possible that’s there some probleme for people to “play” with the records (i m not alone, i seen on this forum a lot of trouble about this).

If i Use ur Dsp solution like i told u, i will loose my synthesis channell cause DSP will receive also the Microphone, also the sound generated by my synth, so it’s totaly unusefull i cannot do anything with that (i used Record.cpp and simply remove the Reverberation stuff, just a pure Copy of sound with Effect)….

/////////// ANOTHER VIEW, perhaps will help ////////////:
I Got a StreamCallBack for the synthesis process
The synthesis process use a GENERATOR Class that will on each evolution (generator->evolue() called for each sample in the StreamCallBack)
Make a output value, then put on *stereobuffer = value; …
Plus now, i wanna to use the microphone as “a synthetiseur” element, that can controle my synth, like if it was a keyboard or stg else.
So i need to Get the each Value of the signal inside the micro (i mean in the buffer… or what u want) and feed my Generator class with that …
Do u understand more ?

StreamCallBack();
{
for (OutputBuffer; …)
{
signed short int VALUE = INPUT (micro) ; // This is my problem
SYNTHESIZE->MICRO_VALUE = VALUE;
SYNTHESIZE->Evolution(); // make all the calcul to procude a sample of sound
*Stereobuffer = SYNTHESIZE->OUTPUT_VAL;
}
}

But, i don’t understand why this is so hard to make. Is there no way for Fmod to have a function or stg, like signed Short Get_Input_Value(); will return the Exact value at the call time. (This will be called 44100 / seconds in my case).

Hope this will help you to help me :)

Tanks, Wax

  • You must to post comments
0
0

no thats impossible, a .1ms buffer = 4 pcm samples at 44khz.

  • You must to post comments
0
0

Yes, ill repost, AGAIN AND AGAIN
I DONT WANT UR DSP EXEMPLE, IS OK BRETT ?
WHAT U THINK IS NOT THE ABSOLUTE ANSWER OF THE UNIVERSE … if i cant found my answer (and i ll found one day .. don’t worry, ill be the first to show u, …)
i ll search in some other lib, slower of FUCKER than fmod, but with a good support …
c u… a man who a lost his mind in FMOD …

  • You must to post comments
0
0

hmmm so i can have a 1s buffer and then take 0.1ms sized samples foraudio analyzing using lock and unlock ?
so the question is, how can i be sure that the part of sound that i takehas a length of exactly 0.1ms ?

  • You must to post comments
0
0

I’d better never used, Fmod.
I’d Better never Asked brett FOR something other that existe in exemple.
I’d Better Answer Myself with a unusefulll answer …

Sorry for all the lose time at all …
IT’s not the first question i ask here, it’s not the last,be sure of that.
BuT everytime, to everyone u give the same Answser ” Look at tjhe XXXX exemple”.
And i m pretty sure there’s not an adequate solution.

I just want to find a way of doing what i want, not making fight with u… but sometime, it’s needed to fight ๐Ÿ˜€ then after find a solution ๐Ÿ˜‰
. Cu

Ps : Si tu (je) on le pouvait, on parelerai la meme langue, et je suis certain qu’on se comprendrai … et je ne m’emballerai pas pour rien ๐Ÿ˜‰

  • You must to post comments
0
0

yes u tried, that’s a fact :) and u seem to not want to abandon ๐Ÿ˜‰ at your honor, tnx. (i loose my temper too easily).

I think too :) this is a recurrent problem, the unclear explanations..

so, i will try to be more clear now. (i asked a friend to translate my text, so u ll perhaps more helped)

what i have:
– a custom stream, which permet myself to have an sound output. so, I fill
this stream with somes signed shorts every 1/44100 seconds (loop inside
callback). for now (and thus for ever), i use this output channel to produce
soud. This sound is the result of a calculation (VCO,VCA,VCF.. dunno if you
see what i mean..).

  • I use my sound generation class and I ask it to evolve every 1/44100th
    second, then i get the output value for put into the stream and so, hear
    something. until there, all’s fine. (for me thought, i’ve sound, and no
    lag :)).

So, i’ve a stream who permit me to fill it how i wanted to, and having sound
output, no matters what i’m calculating in fact.

what i’d want to have:
– Use micro input (line, record input) for get samples from microphone. I do
not talk about hear my voice, thus, this voice should not be outputed to
speakers, and no longer be modded by Fmod anywhere. The value should come
to “me”, and me only, for been threated by my circuit for be outputed on
the stream.

Me, i’ll use the input as another module of my syntethizer and permit
modulation or applying somes effect with my synthetizing system. But this is
no longer needed to be say, only for disturbing your mind ๐Ÿ˜‰

So, i telling myself, why not use as is in example FSOUND_Record_StartSample()
and symply record. Then, i should get the samples been recorded, and this in
real time with loosing somes samples if things getting to slow, in the
worstest vision.

I dunno if i’m much clearer ? i wish to, if not, don’t be effraid to tell me
that you don’t understand me :)

So, as a summary, i’ve my synthetic callback that play sound:

StreamCallBack();
{
for (OutputBuffer; …) // size of buffer
{
SYNTHESIZE->Evolution(); // make all the calcul to produce a sample of sound
*Stereobuffer = SYNTHESIZE->OUTPUT_VAL; // sound output
}
}

Schematiquement:
SYNTHESIZER —————> OUTPUT_STREAM [every Samples]

with this, i’ve got sound, perfectly..

Now i should add some code who will permit to add my microphone support inside
the synthetizer (or an global var, no matters).

Now i do it schematicaly in my idea, maybe not the good one ๐Ÿ˜‰

StreamCallBack();
{
for (OutputBuffer; …)
{
signed short int VALUE = INPUT (micro) ; // This is my problem
SYNTHESIZE->MICRO_VALUE = VALUE;
SYNTHESIZE->Evolution(); // make all the calcul to procude a sample of sound (and if i got a module that use the microphone this module will just have to get SYNTHESIZE->MICRO_VALUE and he can make his sample calculation.)
*Stereobuffer = SYNTHESIZE->OUTPUT_VAL;
}
}

Schematiquement:
MICROPHONE_RECORDING_STREAM ————> SYNTHESIZER —————> OUTPUT_STREAM [every Samples].

  • You must to post comments
0
0

I ll immediatly test what it seems to be what i want :)
I ll keep in contact soon.

Tanks for ur time.

  • You must to post comments
Showing 16 results
Your Answer

Please first to submit.