コード例 #1
0
ファイル: sound.cpp プロジェクト: ralvaradoc/libsf
//////////
//
// Called to play a tone or set of up to five harmonic tones of a specific frequency for a specified duration.
// Returns a handle which can be used to play or terminate the tone.
//
// Note:  Use -1 for hertz entries to disable that tone channel.
//
//////
u64 sound_createTone(SThisCode* thisCode, f32 tfHertz1, f32 tfHertz2, f32 tfHertz3, f32 tfHertz4, u32 tnDurationMilliseconds)
{
    _isSSound*	lss;
    bool		llResult;


    // Was SDL initialized properly?
    if (glSDL_Initialized)
    {
        // Add this item to the list of sounds
        lss = (_isSSound*)iSEChain_append(thisCode, &gseRootSounds, iGetNextUid(thisCode), iGetNextUid(thisCode), sizeof(_isSSound), 1, &llResult);
        if (lss)
        {
            // Store the relevant information
            lss->isStream					= false;
            lss->tone.fHertz1				= tfHertz1;
            lss->tone.fHertz2				= tfHertz2;
            lss->tone.fHertz3				= tfHertz3;
            lss->tone.fHertz4				= tfHertz4;

            // Set our stoppers
            lss->tone.nMilliseconds			= tnDurationMilliseconds;									// How many milliseconds to generate tones for?
            lss->tone.nSamplesToGenerate	= (u32)(gnFrequency * (tnDurationMilliseconds / 1000.0f));	// Based on milliseconds, how many samples to generate?
            lss->tone.nSamplesGenerated		= 0;														// How many samples have been generated thus far?

            // Create our stream buffer
            lss->samples		= (f32*)malloc(gsdlObtained.samples * sizeof(f32));

            // All done
            return(lss->ll.uniqueId);
        }
    }
    // If we get here, failure
    return(-1);
}
コード例 #2
0
ファイル: sound.cpp プロジェクト: ralvaradoc/libsf
//////////
//
// Called to play a stream at the indicated frequency using callbacks.
// Returns a handle which can be used to play or terminate the stream.
//
//////
u64 sound_createStream(SThisCode* thisCode, u32 tnSamplesPerSecond, u64 tnSoundFillerCallbackFunction)
{
    _isSSound*	lss;
    bool		llResult;


    // Was SDL initialized properly?
    if (glSDL_Initialized)
    {
        // Add this item to the list of sounds
        lss = (_isSSound*)iSEChain_append(thisCode, &gseRootSounds, iGetNextUid(thisCode), iGetNextUid(thisCode), sizeof(_isSSound), 1, &llResult);
        if (lss)
        {
            // Store the relevant information
            lss->isStream					= true;
            lss->stream.filler._callback	= tnSoundFillerCallbackFunction;

            // Create our stream buffer
            lss->samples					= (f32*)malloc(gsdlObtained.samples * sizeof(f32));

            // All done
            return(lss->ll.uniqueId);
        }
    }
    // If we get here, failure
    return(-1);
}
コード例 #3
0
ファイル: node.cpp プロジェクト: RickCHodgin/libsf
//////////
//
// Called to render a bitmap which is a visualization of the node
//
//////
	SBitmap* iNode_renderBitmap(SNode* node, s32 tnMaxTokenLength, s32 tnMaxOverallLength, f64 tfRodLength, s32 tnMarginWidth, s32 tnBorderWidth, bool tlIncludeExtraInfo, bool tlGoDeeper, SNodeFlags* nodeFlags, bool tlDeeperNodesExtendInAllDirections)
	{
		s32			lnIter_uid, lnWidth, lnHeight;
		POINTS		p;
		RECT		lrc;
		SBitmap*	bmp;
		SNodeProps	props[1];


		// Make sure our environment is sane
		bmp = NULL;
		if (node)
		{

			//////////
			// (Re-)Render everything
			//////
				// Grab a uid for render
				lnIter_uid = iGetNextUid();

				// Setup the render prop
				props[0].backColor			= whiteColor;
				props[0].foreColor			= blackColor;
				props[0].marginWidth		= tnMarginWidth;
				props[0].fillColor			= silverColor;
				props[0].borderWidth		= tnBorderWidth;
				props[0].borderColor		= darkGrayColor;
				props[0].rodColor			= charcoalColor;
				props[0].colorize			= true;
				props[0].colorizeColor		= pastelBlueColor;
#ifdef iFont_create
				props[0].font				= iFont_create(cgcFontName_defaultFixed);
#endif

				// Render out in all directions from this point
				iiNode_renderBitmap(node, node, NULL, tnMaxTokenLength, tnMaxOverallLength, props, 1, lnIter_uid, tlIncludeExtraInfo, tlGoDeeper, nodeFlags, tlDeeperNodesExtendInAllDirections);


			//////////
			// Determine extents
			//////
				// Grab a uid for get extents
				lnIter_uid = iGetNextUid();

				// Get our starting point
				SetRect(&lrc, 0, 0, 0, 0);
				p.x = 0;
				p.y = 0;

				// Get our extents
				iiNode_get_bitmapExtents(node, node, NULL, _NODE_SE, NULL, &lrc, p, p, tfRodLength, lnIter_uid, props, tlGoDeeper, nodeFlags, tlDeeperNodesExtendInAllDirections);


			//////////
			// Render
			//////
				bmp = iBmp_allocate();
				if (bmp)
				{
					// get our sizes
					lnWidth		= lrc.right - lrc.left;
					lnHeight	= lrc.bottom - lrc.top;

					// Create the bitmap
					iBmp_createBySize(bmp, lnWidth, lnHeight, 24);

					// Grab a uid for get extents
					lnIter_uid = iGetNextUid();

					// Get our starting point
					p.x			= (s16)-lrc.left;
					p.y			= (s16)-lrc.top;
					SetRect(&lrc, 0, 0, lnWidth, lnHeight);

					// Actually render
					iiNode_get_bitmapExtents(node, node, NULL, _NODE_SE, bmp, &lrc, p, p, tfRodLength, lnIter_uid, props, tlGoDeeper, nodeFlags, tlDeeperNodesExtendInAllDirections);
				}

		}

		// Indicate our rendered bitmap
		return(bmp);
	}