0
0

Hello FMOD Community.

I am having some difficulty in trying to stream sound that is playing in a channel to an external .WAV file. My attempts so far only allow me to do something like that from a sound object. None of the provided FMOD examples that I can find seem to offer insight into how this may be done.

I would greatly appreciate some assistance with this.
Thanks!

  • You must to post comments
0
0

Hi Loffer,

The docs for setSoftware format say:
[quote:34gw751h][i:34gw751h]numoutputchannels[/i:34gw751h]

The number of output channels / speakers to initialize the soundcard to. 0 = keep speakermode setting (set with System::setSpeakerMode). If anything else than 0 is specified then the speakermode will be overriden and will become FMOD_SPEAKERMODE_RAW, meaning logical speaker assignments (as defined in FMOD_SPEAKER) become innefective and cannot be used. Channel::setPan will also fail. Default = 2 (FMOD_SPEAKERMODE_STEREO).
[/quote:34gw751h]

Take a look at the documentation for FMOD_SPEAKERMODE_RAW for more information.

  • You must to post comments
0
0

Hi Loffer, welcome to the FMOD Forum!

You can the access the sound data going through a channel using a custom DSP, take a look at the customdsp example.

  • You must to post comments
0
0

Hi, thanks for greeting and help Peter!

I was having a little bit of frustration with a custom DSP so I managed to solve my problem in a different way to get what was in a channel streamed to a .wav file.

I have another problem though. I’d like to get two different sounds from two different channels (channel1, and channel2) now streamed into the .wav file at the one time. I’ve set it up so whatever is in FMOD.Sound sound1 is sent to the external .wav file.

If I try putting both channel1 and channel2 to play in sound1 object, the channel2 sound will be the only one that gets recorded.

How do I combine both channel1 and channel2 into sound1? Is a custom DSP the solution or is there an easier way? 😀

EDIT: I’d also like to add that variations to things in the channels (i.e. variation in volume) is not reflected in the recording based on sound1, though I’d like it to. I imagine this may be something a DSP can fix too, but I think I need to be set on the right path.

  • You must to post comments
0
0

Channels are mixed together in channel groups so you need to get the sound data from the channelgroup. Again I would reccomend the custom DSP method. If you need help with that feel free to post sections of the code you need help with. Basically the approach would be to buffer the sounddata in the custom DSP, the downsample it to 16-bit and write it out to file, when the sound is complete write the wav header. The ‘recordtodisk’ example demonstrates how to write a wav file including the header.

  • You must to post comments
0
0

Thanks yet again Peter!

It’s hard to think where to start in order to get the raw data from a custom DSP.

It seems the ‘recordtodisk’ example uses
[code:2s2pplhg]sound.@lock(lastplaypos * 4, (uint)blocklength * 4, ref ptr1, ref ptr2, ref len1, ref len2);[/code:2s2pplhg]
to get the raw data.

I’m not sure about which equivalent to use in a DSP to get the data from a channel as opposed to a sound object.

EDIT: Wait…that would be part of the downsampling to 16bit, wouldn’t it?

  • You must to post comments
0
0

All good, I got it. I used this as a guide.

[url:3ivv6lai]http://www.fmod.org/forum/viewtopic.php?t=9401&highlight=record[/url:3ivv6lai]

All the channels are now included in the recording. I have one more question: How does one exclude individual channels from being recorded in the DSP?

Any further help would be greatly appreicated.

  • You must to post comments
0
0

The data coming through the DSP is interleaved and so is the data you’re writing to the wav file.

For example say there is stereo sound and you want to record the only the left channel you would take every other sample.

i.e.
[code:nxjuxjdc]LRLRLRLRLRLR -> LLLLLL[/code:nxjuxjdc]

the loop inside the custom DSP would look something like:
[code:nxjuxjdc]for(int frame = 0; frame < length; ++frame)
{
for(int channel = 0; channel < numchannels; ++channel)
{
if (channel == (int)FMOD_SPEAKER_FRONT_LEFT)
{
//write
}
else
{
//discard
}
}
}[/code:nxjuxjdc]

[b:nxjuxjdc]FMOD_SPEAKER[/b:nxjuxjdc]
[code:nxjuxjdc]
FMOD_SPEAKER_FRONT_LEFT,
FMOD_SPEAKER_FRONT_RIGHT,
FMOD_SPEAKER_FRONT_CENTER,
FMOD_SPEAKER_LOW_FREQUENCY,
FMOD_SPEAKER_BACK_LEFT,
FMOD_SPEAKER_BACK_RIGHT,
FMOD_SPEAKER_SIDE_LEFT,
FMOD_SPEAKER_SIDE_RIGHT,
[/code:nxjuxjdc]

  • You must to post comments
0
0

Hi peter, thanks yet again for your quick response.

I’m getting an error when I try to compare ‘channel’ as an int, like in your example to FMOD.SPEAKER.

[code:27jmumi5]Error 1 Operator ‘==’ cannot be applied to operands of type ‘int’ and ‘FMOD.SPEAKER’
[/code:27jmumi5]

Is there something I would be missing? I don’t explicitly refer to channel inside my DSP, but rather inchannels and outchannels.

  • You must to post comments
0
0

Oh yeah you will probably have to cast it for the comparison, I will update the example.

  • You must to post comments
0
0

Thanks peter, that’s working fine for me now!

Though it’s a little bit of a case of one problem leading to another, hopefully this will be my final question.

I’ve noticed that the following line of code, though essentially to put the music into 44100 so I don’t get slowdown in the recording tends to mess up which sound is in what speaker.

[code:1nyh3p1q]result = system.setSoftwareFormat(44100, FMOD.SOUND_FORMAT.PCM16, 2, 0, FMOD.DSP_RESAMPLER.LINEAR);
ERRCHECK(result);[/code:1nyh3p1q]

With that code, one of my sounds can only be heard in the left speaker. When I take it away, I can hear the sound in both speakers.

I’m not understanding why that happens, if you could shed some light on that (especially since it’s probably really off-topic now) that would be fantastic.

  • You must to post comments
Showing 10 results
Your Answer

Please first to submit.