Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

Souldrift

@Souldrift
About
Posts
69
Topics
22
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • GNU Make 3.81 -> make.exe fails [modified]
    S Souldrift

    Hi all, I know I´m probably very wrong in this forum with this topic, but I couldn´t find a better place. Working under Vista, I installed GNU make 3.81 (needed it since we want to use Android NDK, which int turn needs GNU Make). And while make.exe was successfully used by the Android NDK setup script, it fails every time I try to use it to build the example programs. In fact, make.exe even crashes if I just call 'make'. Which is not supposed to happen, I guess. Then a MS window comes up telling me make.exe does not work anymore. Accompanied by another window with the title '16 bit MS-DOS subsystem', saying 'The NTVDM CPU has encountered an illegal instruction...'. This is the according debug output: C:\Users\zwatschek\Stuff\Android\android-ndk-1.6_r1>gmake -d GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for Windows32 Reading makefiles... Reading makefile `GNUmakefile'... Reading makefile `build/core/main.mk' (search path) (no ~ expansion)... Reading makefile `build/core/definitions.mk' (search path) (no ~ expansion)... Reading makefile `build/core/../gmsl/gmsl' (search path) (no ~ expansion)... Reading makefile `build/core/../gmsl/__gmsl' (search path) (no ~ expansion)... Reading makefile `out/host/config.mk' (search path) (no ~ expansion)... Reading makefile `build/core/add-toolchain.mk' (search path) (no ~ expansion)... Reading makefile `build/toolchains/arm-eabi-4.2.1/config.mk' (search path) (no ~ expansion)... Reading makefile `build/core/add-platform.mk' (search path) (no ~ expansion)... Reading makefile `build/core/add-platform.mk' (search path) (no ~ expansion)... Reading makefile `build/core/add-application.mk' (search path) (no ~ expansion). .. Reading makefile `apps/hello-jni/Application.mk' (search path) (no ~ expansion). .. Creating temporary batch file C:\Users\ZWATSC~1\AppData\Local\Temp\make3480-1.ba t CreateProcess(C:\Users\ZWATSC~1\AppData\Local\Temp\make3480-1.bat,C:\Users\ZWATS C~1\AppData\Local\Temp\make3480-1.bat,...) I have no idea what to make of this ... Souldrift

    modified on Monday, December 14, 2009 9:20 AM

    Windows API asp-net android debugging tools tutorial

  • WCHAR and system() call?
    S Souldrift

    Nevermind .. I found it ... _wsystem(). *blush* Souldrift

    C / C++ / MFC question

  • WCHAR and system() call?
    S Souldrift

    Hi there, quick question. How can one use the system() call to start an external exe with a wstring (WCHAR) as parameter? Or is there an alternative? Souldrift

    C / C++ / MFC question

  • TerminateProcess() and windows messages.
    S Souldrift

    Hi there, I got the following problem. For an application that I have already up and running I wrote something like an observer program. The observer simply checks from time to time if the application is still alive and responding. If that is, for whatever reason, no the case, the observer kills the application process (TerminateProcess()) and starts another instance. Now that works quite well so far. Only when a windows error report or such something pops up in the trail of an application crash, the observer is unable to kill the application. So the whole mechanism breaks down. My question is, is there a possibility to kill an application nonetheless? Or to find out what is blocking the killing and to kill that one first then? I could get all the possible process names of the processes that might show up, but that will always leave a hole in the system. Any ideas on that? Souldrift

    C / C++ / MFC question help

  • Mutexes and WaitForSingleObject -> doesn´t wait ??
    S Souldrift

    Yes, that was exactly it. Just found out a minute ago. Thanks a lot. Just tested it with threads and it seems to work allright :). Good day all. Souldrift

    C / C++ / MFC question security lounge

  • Mutexes and WaitForSingleObject -> doesn´t wait ??
    S Souldrift

    There is no error. The return value both times is 0. Which is fine with the first call, and I thought was odd with the second. But I just read somewhere else, that mutexes under windows don´t block inside the same thread. So that might be it. Souldrift

    C / C++ / MFC question security lounge

  • Mutexes and WaitForSingleObject -> doesn´t wait ??
    S Souldrift

    Hello, I just played around with mutexes and wrote the following piece of code:

    HANDLE hMutex = CreateMutex(NULL, // no security descriptor needed in the beginning
    TRUE, // not initial owner
    "test"); // mutex name (hopefully unique)

    DWORD err = WaitForSingleObject(hMutex, INFINITE);
    if( err == WAIT_FAILED )
    printf( "This shouldn´t happen." );
    else
    {
    err = WaitForSingleObject(hMutex, INFINITE);
    if( err == WAIT_FAILED )
    printf( "This shouldn´t happen." );
    else
    printf( "This shouldn´t happen either." );
    }

    No I don´t understand why the second WaitForSingleObject()-call doesn´t block. Since I said to wait indefinitely, shouldn´t it do so because the mutex object is already in use? I guess, I have some general trouble understanding the mechanism here. How do I get the mutex to lock a code area up? Souldrift

    C / C++ / MFC question security lounge

  • Shell title
    S Souldrift

    God, I couldn´t find that anywhere. You are my hero today :). Thanks. Souldrift

    C / C++ / MFC question c++ linux

  • Shell title
    S Souldrift

    Good morning :), quick question. How do I set the shell title for a c++ program? Souldrift

    C / C++ / MFC question c++ linux

  • Enigma with ShellExecute ? [modified]
    S Souldrift

    I found it. What a bugger. I got my file name from an absolute path like this

    string path = wdPath.substr( 0, index+1 );
    string file = wdPath.substr( index+1 );

    And though 'file' was displayed correctly in the watch, it seems to have contained some invalid sign. Cause like this ...

    string path = wdPath.substr( 0, index+1 );
    string file = wdPath.substr( index+1, wdPath.size()-index-2 );

    ... it works. Cheers Souldrift

    C / C++ / MFC help collaboration question announcement

  • Enigma with ShellExecute ? [modified]
    S Souldrift

    God, how I hate programming :mad: Thanks again ...

    C / C++ / MFC help collaboration question announcement

  • Enigma with ShellExecute ? [modified]
    S Souldrift

    I edited the code block. buf was initialized, of course, further above. In ShellExecute() I tried 'callString' and 'buf' as parameter. But only 'buf' worked. 'buf' is in the example NOT in the ShellExecute(), since I tried last with 'callString'. hm ... I post the code differently ...

    char buf[512]
    size = GetCurrentDirectoryA( 512, buf ); // get absolute path

    char id[32];
    sprintf_s( id, "%d", pid );

    // version 1
    char callString[1024];
    sprintf_s( callString, "%s\\%s", buf, file.c_str() );
    long res=long(ShellExecute(0, "open", callString, id, 0, SW_SHOWNORMAL));

    // version 2
    char callString2[1024];
    sprintf_s( callString2, "c:\\Users\\zwatschek\\work\\svn\\incubation\\ttsServer\\Data\\ttsWatchdog.exe" );
    res=long(ShellExecute(0, "open", callString2, id, 0, SW_SHOWNORMAL));

    And still, the contents of callString and callString2 are the same. Version 2 works, version 1 not. I´ll look into the len parameter of sprintf_s. But I don´t think that´s it. Thanks. Souldrift

    modified on Monday, October 5, 2009 5:26 AM

    C / C++ / MFC help collaboration question announcement

  • Enigma with ShellExecute ? [modified]
    S Souldrift

    Hi there, I got the strangest problem. I want to start an executable with ShellExecute(). Which usually works fine, but ... (this is the code)

    [edit]
    char buf[512]
    size = GetCurrentDirectoryA( 512, buf ); // get absolute path
    [/edit]

    // version 1
    char callString[1024];
    sprintf_s( callString, "%s\\%s", buf, file.c_str() );
    // version 2
    char buf[1024];
    sprintf_s( buf, "c:\\Users\\zwatschek\\work\\svn\\incubation\\ttsServer\\Data\\ttsWatchdog.exe" );

    char id[32];
    sprintf_s( id, "%d", pid );

    long res=long(ShellExecute(0, "open", callString, id, 0, SW_SHOWNORMAL));

    ... with version 2 things work fine, with version 1 I get ERROR_FILE_NOT_FOUND. callString = c:\Users\zwatschek\work\svn\incubation\ttsServer\Data\ttsWatchdog.exe buf = c:\Users\zwatschek\work\svn\incubation\ttsServer\Data\ttsWatchdog.exe (I copied those strings right out from the variable watch) Does anyone have an idea on this? Souldrift

    modified on Monday, October 5, 2009 5:00 AM

    C / C++ / MFC help collaboration question announcement

  • Calling external exe in separate shell?
    S Souldrift

    Hi there, I got trouble with calling externals. Maybe somebody can help me. I used to call external programs (exe-files) with the system() call. Now I want to start an external program in a seperate shell (and as a separate process). Can anybody tell me how to do that? Thanks a lot. Souldrift

    C / C++ / MFC linux help tutorial question

  • How to write mic data to .wav file ?
    S Souldrift

    Well, nevermind. I just fixed it :). Modified the save function like this:

    bool save()
    {
    int bitsPerSample = 16;
    int subchunk1size = 16;
    int numChannels = 1;
    int subchunk2size = WaveInHdr.dwBufferLength*numChannels;
    int chunksize = 36+subchunk2size;
    int audioFormat = 1;
    int byteRate = sampleRate*numChannels*bitsPerSample/8;
    int blockAlign = numChannels*bitsPerSample/8;

    fstream myFile ("test.wav", ios::out | ios::binary);
    
    // write the wav file per the wav file format
    myFile.seekp (0, ios::beg); 
    myFile.write ("RIFF", 4);					// chunk id
    myFile.write ((char\*) &chunksize, 4);	        	// chunk size (36 + SubChunk2Size))
    myFile.write ("WAVE", 4);					// format
    myFile.write ("fmt ", 4);					// subchunk1ID
    myFile.write ((char\*) &subchunk1size, 4);			// subchunk1size (16 for PCM)
    myFile.write ((char\*) &audioFormat, 2);			// AudioFormat (1 for PCM)
    myFile.write ((char\*) &numChannels, 2);			// NumChannels
    myFile.write ((char\*) &sampleRate, 4);			// sample rate
    myFile.write ((char\*) &byteRate, 4);			// byte rate (SampleRate \* NumChannels \* BitsPerSample/8)
    myFile.write ((char\*) &blockAlign, 2);			// block align (NumChannels \* BitsPerSample/8)
    myFile.write ((char\*) &bitsPerSample, 2);			// bits per sample
    myFile.write ("data", 4);					// subchunk2ID
    myFile.write ((char\*) &subchunk2size, 4);			// subchunk2size (NumSamples \* NumChannels \* BitsPerSample/8)
    	
    myFile.write (WaveInHdr.lpData, WaveInHdr.dwBufferLength);	// data
    
    return true;
    

    }

    Cheers Souldrift

    C / C++ / MFC ios help tutorial question

  • How to write mic data to .wav file ?
    S Souldrift

    Good morning, I have trouble creating a wave file from the data stream I got from the microphone input. The recording seems to go quite well but know I´m stuck at the task of converting that data into a wave file. I recorded the mic data into a WAVEHDR structure like this ...

    const int NUMPTS = 44100 * 10; // 10 seconds
    int sampleRate = 44100;
    short int waveIn[NUMPTS]; // 'short int' is a 16-bit type; I request 16-bit samples below
    // for 8-bit capture, you'd use 'unsigned char' or 'BYTE' 8-bit types

    HWAVEIN hWaveIn;
    WAVEHDR WaveInHdr;
    MMRESULT result;

    int main( int argc, char *argv[] )
    {
    // Specify recording parameters
    WAVEFORMATEX pFormat;
    pFormat.wFormatTag=WAVE_FORMAT_PCM; // simple, uncompressed format
    pFormat.nChannels=1; // 1=mono, 2=stereo
    pFormat.nSamplesPerSec=sampleRate; // 44100
    pFormat.nAvgBytesPerSec=sampleRate*2; // = nSamplesPerSec * n.Channels * wBitsPerSample/8
    pFormat.nBlockAlign=2; // = n.Channels * wBitsPerSample/8
    pFormat.wBitsPerSample=16; // 16 for high quality, 8 for telephone-grade
    pFormat.cbSize=0;

    result = waveInOpen(&hWaveIn, WAVE\_MAPPER,&pFormat, 0L, 0L, WAVE\_FORMAT\_DIRECT);
    if (result)
    {
    	char fault\[256\];
    	waveInGetErrorText(result, fault, 256);
    
    	return 1;
    }
    
    // Set up and prepare header for input
    WaveInHdr.lpData = (LPSTR)waveIn;
    WaveInHdr.dwBufferLength = NUMPTS\*2;
    WaveInHdr.dwBytesRecorded=0;
    WaveInHdr.dwUser = 0L;
    WaveInHdr.dwFlags = 0L;
    WaveInHdr.dwLoops = 0L;
    waveInPrepareHeader(hWaveIn, &WaveInHdr, sizeof(WAVEHDR));
    
    // Insert a wave input buffer
    result = waveInAddBuffer(hWaveIn, &WaveInHdr, sizeof(WAVEHDR));
    if (result)
    {
    	return 1;
    }
    
    
    // Commence sampling input
    result = waveInStart(hWaveIn);
    if (result)
    {
    	return 1;
    }
    
    
    // Wait until finished recording
    do
    {
    	// record for 10 seconds
    } 
    while (waveInUnprepareHeader(hWaveIn, &WaveInHdr, sizeof(WAVEHDR))==WAVERR\_STILLPLAYING);
    
    waveInClose(hWaveIn);
    
    save();
    
    std::cin.get();
    return 0;
    

    }

    ... and now I am trying to store the data to a wave file like this:

    bool save()
    {
    int subchunk2size = WaveInHdr.dwBufferLength*1*2;

    fstream myFile ("test.wav", ios::out | ios::binary);
    
    // write the wav file per the wav file format
    myFile.seekp (0, ios::beg); 
    myFile.write ("RIFF", 4);					// chunk id
    myFile.write ((char\*) 36+subchunk2size, 4);			// chunk size (36 + SubChunk2Size)
    
    C / C++ / MFC ios help tutorial question

  • zero termination for BYTE?
    S Souldrift

    Thanks. That´s what I thought. Only someone asked me a question about the topic and got me quite confused. Souldrift

    C / C++ / MFC question ios tutorial

  • zero termination for BYTE?
    S Souldrift

    Hi there, this might be a slightly stupid question, but when I write a single BYTE into a file (using ofstream), does it need to be null-terminated? Do BYTE streams generally have to be? Example code:

    char* buf = new char[128];
    sprintf_s( buf, 128, "TestOutput/RTPEngineBin%04d.out", m_iFileCount );

    m_oStream3.open(buf, ios::out|ios::binary);

    if( !m_oStream3 )
    {
    // ...
    }

    for( int i = 0; i < 12; i++ )
    {
    m_oStream3 << header[i];
    }

    m_oStream3 << data; // data == 1 BYTE

    m_oStream3.flush();
    m_oStream3.close();

    delete [] buf;

    This is a small rtp package. Header has 12 bytes and the payload is just a single byte. Cheers Souldrift

    C / C++ / MFC question ios tutorial

  • byte to int -&gt; bit shifting confusion [modified]
    S Souldrift

    Yes, that´s it. Thank´s a lot. Just found out that it was a signed/unsigned issue. Didn´t know, though, why java would make a difference between

    int time = data[3];

    result is -16 and

    int time = data[3] & 0xff;

    result is 240 (data[3] being a byte holding 11110000) So thanks again. I love this forum :). Souldrift

    C / C++ / MFC help c++ java data-structures question

  • byte to int -&gt; bit shifting confusion [modified]
    S Souldrift

    I know, thanks. the m_aHeader[7] 0xff was a typo. and yes, there should be no difference. I just updated my post, since I found the difference is only in java :(.

    C / C++ / MFC help c++ java data-structures question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups