Login Page - Create Account

Support Board


Date/Time: Sun, 16 Mar 2025 02:57:36 +0000



[Programming Help] - DLL makes program unstable / CPU Exception

View Count: 996

[2021-12-10 01:40:37]
KylieV1618 - Posts: 67
Im compiling a study in Visual Studio 2019. (yay finally figured out how).

But now Im running into an issue when I attach the study to my chart it says,.,...

Warning: This Custom DLL study may cause Sierra Chart to be unstable until you remove the study from the chart and restart Sierra Chart. | 2021-12-09 17:34:27.753 *
Warning: The Custom DLL study "SierraChartAudio.scsf_AudioTest" has just caused a CPU exception. | 2021-12-09 17:34:29.890 *


And it just keeps going.

The code is simply importing a sound library called cute_sound.



// The top of every source code file must include this line
#include "sierrachart.h"
#define CUTE_SOUND_IMPLEMENTATION
#include <cute_sound.h>

SCDLLName("DOES_THIS_FUCKING_WORK_2")

// Some global variables that I want to use in other studies, all linked to same sound context.
cs_loaded_sound_t wave1;
cs_playing_sound_t wave1Instance;
cs_context_t* ctx;
HWND hwnd;


void initSound() {
hwnd = GetConsoleWindow();
ctx = cs_make_context(hwnd, 44100, 8192, 0, NULL);
wave1 = cs_load_wav("C:\pathtosound etc");
wave1Instance = cs_make_playing_sound(&wave1);

// Play the sound to test its working
cs_insert_sound(ctx, &wave1Instance);

}


... rest of my study code



Then I have it in one study, initializing it.


SCSFExport scsf_AudioTest(SCStudyInterfaceRef sc)
{  
  if (sc.SetDefaults)
  {
    sc.GraphName = "AusioTest";

    sc.AutoLoop = 0;
    sc.GraphRegion = 0;

initSound();

    return;
  }

}

And this just causes the DLL error that says CPU Exception. That then seems to run in a loop. Which is wierd because I thought setDefaults was only supposed to be called once??
Date Time Of Last Edit: 2021-12-10 01:42:19
[2021-12-13 06:44:43]
User99735 - Posts: 234
Can you provide details of exception - line no / message etc, which will appear when Visual Studio is attached to the Sierra Chart process.
[2021-12-13 09:26:53]
User907968 - Posts: 838
Which is wierd because I thought setDefaults was only supposed to be called once??
Once for each study instance, and when you press 'Add Custom Study' button - explained here - ACSIL Interface Members - Variables and Arrays: sc.SetDefaults

Suggest moving the initSound call outside of the setdefaults block, for example: ACSIL Programming Concepts: Study Initialization/Unitialization

Also, maybe you could wrap the global variables into a singleton class and guarantee that they are only initialised once.
[2022-08-05 18:31:24]
User395175 - Posts: 90
Have you solved the problem? And how?

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account