0

I have verified that my frequency(note) function returns the correct frequency as an int. However, when I attempt to write out using the "command-line note entry" testing scenario described (and yes i did hit ctrl-D to issue EOF), the .wav file that is output is nothing but the header and zero's trailing it

5249 4646 ac58 0100 5741 5645 666d 7420
1000 0000 0100 0100 44ac 0000 8858 0100
0200 1000 6461 7461 8858 0100 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 
... to line 5516 ...
0000 0000

Testing the frequency function in isolation (in file temp.c), just to verify

int frequency(string note);

int main(int argc, string argv[]){
    if(argc != 2)
    {
        printf("Usage: %s NOTE\n", argv[0]);
        return 1;
    }
    printf("%i", frequency(argv[1]));
}

int frequency(string note){ ... <code not shown> ... }

, here's the output:

~/workspace/ $ make temp 
clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow    temp.c  -lcrypt -lcs50 -lm -o temp
~/workspace/ $ ./temp A4
440~/workspace/ $ 

Any ideas?

Also this says pset3 on the 2018 cs50 site, but pset3 here looks like some puzzle game???

1

1 Answer 1

0

Maybe is_rest is always returning true. It should return true only for strings of length zero, or equivalently those starting with the null terminator.

3
  • Switched my is_rest to return (strlen(s) == 0) and now I get a segmentation fault. ~/workspace/pset3/music/ $ ./synthesize tester2.wav A4 helpers.c:15:22: runtime error: null pointer passed as argument 1, which is declared to never be null /usr/include/stdlib.h:148:33: note: nonnull attribute specified here Segmentation fault Commented Jul 16, 2018 at 16:34
  • So what is at helpers.c:15:22?
    – Blauelf
    Commented Jul 16, 2018 at 16:38
  • And does the segmentation fault also happen if you use a file for input, like ./synthesize boat.wav < songs/boat.txt? (that way you can exclude it's your fault with manual input) If you're using manual input, don't forget the duration part.
    – Blauelf
    Commented Jul 16, 2018 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .